Completed
Push — add/changelog-66 ( 3dd88f...f645f6 )
by Jeremy
27:12 queued 17:45
created

Sharing_Admin::wrapper_admin_page()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
if ( ! defined( 'WP_SHARING_PLUGIN_URL' ) ) {
3
	define( 'WP_SHARING_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
4
	define( 'WP_SHARING_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
5
}
6
7
class Sharing_Admin {
8
	public function __construct() {
9
		require_once WP_SHARING_PLUGIN_DIR . 'sharing-service.php';
10
11
		add_action( 'admin_init', array( &$this, 'admin_init' ) );
12
		add_action( 'admin_menu', array( &$this, 'subscription_menu' ) );
13
14
		// Insert our CSS and JS
15
		add_action( 'load-settings_page_sharing', array( &$this, 'sharing_head' ) );
16
17
		// Catch AJAX
18
		add_action( 'wp_ajax_sharing_save_services', array( &$this, 'ajax_save_services' ) );
19
		add_action( 'wp_ajax_sharing_save_options', array( &$this, 'ajax_save_options' ) );
20
		add_action( 'wp_ajax_sharing_new_service', array( &$this, 'ajax_new_service' ) );
21
		add_action( 'wp_ajax_sharing_delete_service', array( &$this, 'ajax_delete_service' ) );
22
	}
23
24
	public function sharing_head() {
25
		wp_enqueue_script(
26
			'sharing-js',
27
			Jetpack::get_file_url_for_environment(
28
				'_inc/build/sharedaddy/admin-sharing.min.js',
29
				'modules/sharedaddy/admin-sharing.js'
30
			),
31
			array( 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-form' ),
32
			2
33
		);
34
35
		/**
36
		 * Filters the switch that if set to true allows Jetpack to use minified assets. Defaults to true
37
		 * if the SCRIPT_DEBUG constant is not set or set to false. The filter overrides it.
38
		 *
39
		 * @since 6.2.0
40
		 *
41
		 * @param boolean $var should Jetpack use minified assets.
42
		 */
43
		$postfix = apply_filters( 'jetpack_should_use_minified_assets', true ) ? '.min' : '';
44
		if ( is_rtl() ) {
45
			wp_enqueue_style( 'sharing-admin', WP_SHARING_PLUGIN_URL . 'admin-sharing-rtl' . $postfix . '.css', false, JETPACK__VERSION );
46
		} else {
47
			wp_enqueue_style( 'sharing-admin', WP_SHARING_PLUGIN_URL . 'admin-sharing' . $postfix . '.css', false, JETPACK__VERSION );
48
		}
49
		wp_enqueue_style( 'sharing', WP_SHARING_PLUGIN_URL . 'sharing.css', false, JETPACK__VERSION );
50
51
		wp_enqueue_style( 'social-logos' );
52
		wp_enqueue_script( 'sharing-js-fe', WP_SHARING_PLUGIN_URL . 'sharing.js', array(), 4 );
53
		add_thickbox();
54
	}
55
56
	public function admin_init() {
57
		if ( isset( $_GET['page'] ) && ( $_GET['page'] == 'sharing.php' || $_GET['page'] == 'sharing' ) ) {
58
			$this->process_requests();
59
		}
60
	}
61
62
	public function process_requests() {
63
		if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options' ) ) {
64
			$sharer = new Sharing_Service();
65
			$sharer->set_global_options( $_POST );
66
			/**
67
			 * Fires when updating sharing settings.
68
			 *
69
			 * @module sharedaddy
70
			 *
71
			 * @since 1.1.0
72
			 */
73
			do_action( 'sharing_admin_update' );
74
75
			wp_safe_redirect( admin_url( 'options-general.php?page=sharing&update=saved' ) );
76
			die();
77
		}
78
	}
79
80
	public function subscription_menu( $user ) {
81
		if ( ! defined( 'IS_WPCOM' ) || ! IS_WPCOM ) {
82
			$active = Jetpack::get_active_modules();
83
			if ( ! in_array( 'publicize', $active ) && ! current_user_can( 'manage_options' ) ) {
84
				return;
85
			}
86
		}
87
88
		add_submenu_page(
89
			'options-general.php',
90
			__( 'Sharing Settings', 'jetpack' ),
91
			__( 'Sharing', 'jetpack' ),
92
			'publish_posts',
93
			'sharing',
94
			array( &$this, 'wrapper_admin_page' )
95
		);
96
	}
97
98
	public function ajax_save_services() {
99
		if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options' ) && isset( $_POST['hidden'] ) && isset( $_POST['visible'] ) ) {
100
			$sharer = new Sharing_Service();
101
102
			$sharer->set_blog_services( explode( ',', $_POST['visible'] ), explode( ',', $_POST['hidden'] ) );
103
			die();
104
		}
105
	}
106
107
	public function ajax_new_service() {
108
		if ( isset( $_POST['_wpnonce'] ) && isset( $_POST['sharing_name'] ) && isset( $_POST['sharing_url'] ) && isset( $_POST['sharing_icon'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-new_service' ) ) {
109
			$sharer = new Sharing_Service();
110
			if ( $service = $sharer->new_service( stripslashes( $_POST['sharing_name'] ), stripslashes( $_POST['sharing_url'] ), stripslashes( $_POST['sharing_icon'] ) ) ) {
111
				$this->output_service( $service->get_id(), $service );
112
				echo '<!--->';
113
				$service->button_style = 'icon-text';
114
				$this->output_preview( $service );
115
116
				die();
117
			}
118
		}
119
120
		// Fail
121
		die( '1' );
122
	}
123
124
	public function ajax_delete_service() {
125
		if ( isset( $_POST['_wpnonce'] ) && isset( $_POST['service'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options_' . $_POST['service'] ) ) {
126
			$sharer = new Sharing_Service();
127
			$sharer->delete_service( $_POST['service'] );
128
		}
129
	}
130
131
	public function ajax_save_options() {
132
		if ( isset( $_POST['_wpnonce'] ) && isset( $_POST['service'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options_' . $_POST['service'] ) ) {
133
			$sharer = new Sharing_Service();
134
			$service = $sharer->get_service( $_POST['service'] );
135
136
			if ( $service && $service instanceof Sharing_Advanced_Source ) {
137
				$service->update_options( $_POST );
138
139
				$sharer->set_service( $_POST['service'], $service );
140
			}
141
142
			$this->output_service( $service->get_id(), $service, true );
143
			echo '<!--->';
144
			$service->button_style = 'icon-text';
145
			$this->output_preview( $service );
146
			die();
147
		}
148
	}
149
150
	public function output_preview( $service ) {
151
		$klasses = array( 'advanced', 'preview-item' );
152
153
		if ( $service->button_style != 'text' || $service->has_custom_button_style() ) {
154
			$klasses[] = 'preview-' . $service->get_class();
155
			$klasses[] = 'share-' . $service->get_class();
156
157
			if ( $service->get_class() != $service->get_id() ) {
158
				$klasses[] = 'preview-' . $service->get_id();
159
			}
160
		}
161
162
		echo '<li class="' . implode( ' ', $klasses ) . '">';
163
		$service->display_preview();
164
		echo '</li>';
165
	}
166
167
	public function output_service( $id, $service, $show_dropdown = false ) {
168
?>
169
	<li class="service advanced share-<?php echo $service->get_class(); ?>" id="<?php echo $service->get_id(); ?>" tabindex="0">
170
		<span class="options-left"><?php echo esc_html( $service->get_name() ); ?></span>
171
		<?php if ( 0 === strpos( $service->get_id(), 'custom-' ) || $service->has_advanced_options() ) : ?>
172
		<span class="close"><a href="#" class="remove">&times;</a></span>
173
		<form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>">
174
			<input type="hidden" name="action" value="sharing_delete_service" />
175
			<input type="hidden" name="service" value="<?php echo esc_attr( $id ); ?>" />
176
			<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-options_' . $id );?>" />
177
		</form>
178
		<?php endif; ?>
179
	</li>
180
<?php
181
	}
182
183
	public function wrapper_admin_page() {
184
		Jetpack_Admin_Page::wrap_ui( array( &$this, 'management_page' ), array( 'is-wide' =>true ) );
185
	}
186
187
	public function management_page() {
188
		$sharer	 = new Sharing_Service();
189
		$enabled = $sharer->get_blog_services();
190
		$global	 = $sharer->get_global_options();
191
192
		$shows = array_values( get_post_types( array( 'public' => true ) ) );
193
		array_unshift( $shows, 'index' );
194
195
		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...
196
			echo '<div id="message" class="updated fade"><h3>' . __( 'Warning! Multibyte support missing!', 'jetpack' ) . '</h3>';
197
			echo '<p>' . sprintf( __( 'This plugin will work without it, but multibyte support is used <a href="%s" rel="noopener noreferrer" 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>';
198
		}
199
200
		if ( isset( $_GET['update'] ) && $_GET['update'] == 'saved' ) {
201
			echo '<div class="updated"><p>' . __( 'Settings have been saved', 'jetpack' ) . '</p></div>';
202
		}
203
204
		if ( ! isset( $global['sharing_label'] ) ) {
205
			$global['sharing_label'] = __( 'Share this:', 'jetpack' );
206
		}
207
?>
208
209
	<div class="wrap">
210
		<div class="icon32" id="icon-options-general"><br /></div>
211
		<h1><?php _e( 'Sharing Settings', 'jetpack' ); ?></h1>
212
213
		<?php
214
		/**
215
		 * Fires at the top of the admin sharing settings screen.
216
		 *
217
		 * @module sharedaddy
218
		 *
219
		 * @since 1.6.0
220
		 */
221
		do_action( 'pre_admin_screen_sharing' );
222
		?>
223
224
		<?php if ( current_user_can( 'manage_options' ) ) : ?>
225
226
		<div class="share_manage_options">
227
		<h2><?php _e( 'Sharing Buttons', 'jetpack' ) ?></h2>
228
		<p><?php _e( 'Add sharing buttons to your blog and allow your visitors to share posts with their friends.', 'jetpack' ) ?></p>
229
230
		<div id="services-config">
231
			<table id="available-services">
232
					<tr>
233
					<td class="description">
234
						<h3><?php _e( 'Available Services', 'jetpack' ); ?></h3>
235
						<p><?php _e( "Drag and drop the services you'd like to enable into the box below.", 'jetpack' ); ?></p>
236
						<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>
237
					</td>
238
					<td class="services">
239
						<ul class="services-available" style="height: 100px;">
240
							<?php foreach ( $sharer->get_all_services_blog() as $id => $service ) : ?>
241
								<?php
242
								if ( ! isset( $enabled['all'][ $id ] ) ) {
243
										$this->output_service( $id, $service );
244
								}
245
									?>
246
							<?php endforeach; ?>
247
						</ul>
248
						<?php
249
						if ( -1 == get_option( 'blog_public' ) ) {
250
							echo '<p><strong>' . __( 'Please note that your services have been restricted because your site is private.', 'jetpack' ) . '</strong></p>';
251
						}
252
						?>
253
						<br class="clearing" />
254
					</td>
255
					</tr>
256
			</table>
257
258
			<table id="enabled-services">
259
				<tr>
260
					<td class="description">
261
						<h3>
262
							<?php _e( 'Enabled Services', 'jetpack' ); ?>
263
							<img src="<?php echo admin_url( 'images/loading.gif' ); ?>" width="16" height="16" alt="loading" style="vertical-align: middle; display: none" />
264
						</h3>
265
						<p><?php _e( 'Services dragged here will appear individually.', 'jetpack' ); ?></p>
266
					</td>
267
					<td class="services" id="share-drop-target">
268
							<h2 id="drag-instructions" <?php if ( count( $enabled['visible'] ) > 0 ) { echo ' style="display: none"';} ?>><?php _e( 'Drag and drop available services here.', 'jetpack' ); ?></h2>
269
270
								<ul class="services-enabled">
271
									<?php foreach ( $enabled['visible'] as $id => $service ) : ?>
272
										<?php $this->output_service( $id, $service, true ); ?>
273
									<?php endforeach; ?>
274
275
									<li class="end-fix"></li>
276
								</ul>
277
					</td>
278
					<td id="hidden-drop-target" class="services">
279
							<p><?php _e( 'Services dragged here will be hidden behind a share button.', 'jetpack' ); ?></p>
280
281
							<ul class="services-hidden">
282
									<?php foreach ( $enabled['hidden'] as $id => $service ) : ?>
283
										<?php $this->output_service( $id, $service, true ); ?>
284
									<?php endforeach; ?>
285
									<li class="end-fix"></li>
286
							</ul>
287
					</td>
288
				</tr>
289
			</table>
290
291
			<table id="live-preview">
292
				<tr>
293
					<td class="description">
294
						<h3><?php _e( 'Live Preview', 'jetpack' ); ?></h3>
295
					</td>
296
					<td class="services">
297
						<h2 <?php echo ( count( $enabled['all'] ) > 0 ) ? ' style="display: none"' : ''; ?>><?php _e( 'Sharing is off. Add services above to enable.', 'jetpack' ); ?></h2>
298
						<div class="sharedaddy sd-sharing-enabled">
299
							<?php if ( count( $enabled['all'] ) > 0 ) : ?>
300
							<h3 class="sd-title"><?php echo esc_html( $global['sharing_label'] ); ?></h3>
301
							<?php endif; ?>
302
							<div class="sd-content">
303
								<ul class="preview">
304
									<?php foreach ( $enabled['visible'] as $id => $service ) : ?>
305
										<?php $this->output_preview( $service ); ?>
306
									<?php endforeach; ?>
307
308
									<?php if ( count( $enabled['hidden'] ) > 0 ) : ?>
309
									<li class="advanced"><a href="#" class="sharing-anchor sd-button share-more"><span><?php _e( 'More', 'jetpack' ); ?></span></a></li>
310
									<?php endif; ?>
311
								</ul>
312
313
								<?php if ( count( $enabled['hidden'] ) > 0 ) : ?>
314
								<div class="sharing-hidden">
315
									<div class="inner" style="display: none; <?php echo count( $enabled['hidden'] ) == 1 ? 'width:150px;' : ''; ?>">
316
										<?php if ( count( $enabled['hidden'] ) == 1 ) : ?>
317
											<ul style="background-image:none;">
318
										<?php else : ?>
319
											<ul>
320
										<?php endif; ?>
321
322
										<?php
323
										foreach ( $enabled['hidden'] as $id => $service ) {
324
											$this->output_preview( $service );
325
										}
326
										?>
327
										</ul>
328
									</div>
329
								</div>
330
								<?php endif; ?>
331
332
								<ul class="archive" style="display:none;">
333
								<?php
334
								foreach ( $sharer->get_all_services_blog() as $id => $service ) :
335
									if ( isset( $enabled['visible'][ $id ] ) ) {
336
										$service = $enabled['visible'][ $id ];
337
									} elseif ( isset( $enabled['hidden'][ $id ] ) ) {
338
										$service = $enabled['hidden'][ $id ];
339
									}
340
341
									$service->button_style = 'icon-text';	// The archive needs the full text, which is removed in JS later
342
									$service->smart = false;
343
									$this->output_preview( $service );
344
									endforeach; ?>
345
									<li class="advanced"><a href="#" class="sharing-anchor sd-button share-more"><span><?php _e( 'More', 'jetpack' ); ?></span></a></li>
346
								</ul>
347
							</div>
348
						</div>
349
						<br class="clearing" />
350
					</td>
351
				</tr>
352
			</table>
353
354
				<form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>" id="save-enabled-shares">
355
					<input type="hidden" name="action" value="sharing_save_services" />
356
					<input type="hidden" name="visible" value="<?php echo implode( ',', array_keys( $enabled['visible'] ) ); ?>" />
357
					<input type="hidden" name="hidden" value="<?php echo implode( ',', array_keys( $enabled['hidden'] ) ); ?>" />
358
					<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-options' );?>" />
359
				</form>
360
		</div>
361
362
		<form method="post" action="">
363
			<table class="form-table">
364
				<tbody>
365
					<tr valign="top">
366
						<th scope="row"><label><?php _e( 'Button style', 'jetpack' ); ?></label></th>
367
						<td>
368
							<select name="button_style" id="button_style">
369
								<option<?php echo ( $global['button_style'] == 'icon-text' ) ? ' selected="selected"' : ''; ?> value="icon-text"><?php _e( 'Icon + text', 'jetpack' ); ?></option>
370
								<option<?php echo ( $global['button_style'] == 'icon' ) ? ' selected="selected"' : ''; ?> value="icon"><?php _e( 'Icon only', 'jetpack' ); ?></option>
371
								<option<?php echo ( $global['button_style'] == 'text' ) ? ' selected="selected"' : ''; ?> value="text"><?php _e( 'Text only', 'jetpack' ); ?></option>
372
								<option<?php echo ( $global['button_style'] == 'official' ) ? ' selected="selected"' : ''; ?> value="official"><?php _e( 'Official buttons', 'jetpack' ); ?></option>
373
							</select>
374
						</td>
375
					</tr>
376
					<tr valign="top">
377
						<th scope="row"><label><?php _e( 'Sharing label', 'jetpack' ); ?></label></th>
378
						<td>
379
							<input type="text" name="sharing_label" value="<?php echo esc_attr( $global['sharing_label'] ); ?>" />
380
						</td>
381
					</tr>
382
					<?php
383
					/**
384
					 * Filters the HTML at the beginning of the "Show button on" row.
385
					 *
386
					 * @module sharedaddy
387
					 *
388
					 * @since 2.1.0
389
					 *
390
					 * @param string $var Opening HTML tag at the beginning of the "Show button on" row.
391
					 */
392
					echo apply_filters( 'sharing_show_buttons_on_row_start', '<tr valign="top">' );
393
					?>
394
						<th scope="row"><label><?php _e( 'Show buttons on', 'jetpack' ); ?></label></th>
395
							<td>
396
								<?php
397
								$br = false;
398 View Code Duplication
								foreach ( $shows as $show ) :
399
									if ( 'index' == $show ) {
400
										$label = __( 'Front Page, Archive Pages, and Search Results', 'jetpack' );
401
									} else {
402
										$post_type_object = get_post_type_object( $show );
403
										$label = $post_type_object->labels->name;
404
									}
405
								?>
406
								<?php
407
								if ( $br ) {
408
									echo '<br />';
409
								}
410
								?>
411
								<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>
412
								<?php
413
								$br = true;
414
								endforeach;
415
								?>
416
							</td>
417
					<?php
418
					/**
419
					 * Filters the HTML at the end of the "Show button on" row.
420
					 *
421
					 * @module sharedaddy
422
					 *
423
					 * @since 2.1.0
424
					 *
425
					 * @param string $var Closing HTML tag at the end of the "Show button on" row.
426
					 */
427
					echo apply_filters( 'sharing_show_buttons_on_row_end', '</tr>' );
428
					?>
429
430
					<?php
431
					/**
432
					 * Fires at the end of the sharing global options settings table.
433
					 *
434
					 * @module sharedaddy
435
					 *
436
					 * @since 1.1.0
437
					 */
438
					do_action( 'sharing_global_options' );
439
					?>
440
				</tbody>
441
			</table>
442
443
			<p class="submit">
444
					<input type="submit" name="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'jetpack' ); ?>" />
445
			</p>
446
447
				<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-options' );?>" />
448
		</form>
449
450
	<div id="new-service" style="display: none">
451
		<form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>" id="new-service-form">
452
			<table class="form-table">
453
				<tbody>
454
					<tr valign="top">
455
						<th scope="row" width="100"><label><?php _e( 'Service name', 'jetpack' ); ?></label></th>
456
						<td>
457
							<input type="text" name="sharing_name" id="new_sharing_name" size="40" />
458
						</td>
459
					</tr>
460
					<tr valign="top">
461
						<th scope="row" width="100"><label><?php _e( 'Sharing URL', 'jetpack' ); ?></label></th>
462
						<td>
463
							<input type="text" name="sharing_url" id="new_sharing_url" size="40" />
464
465
							<p><?php _e( 'You can add the following variables to your service sharing URL:', 'jetpack' ); ?><br/>
466
							<code>%post_id%</code>, <code>%post_title%</code>, <code>%post_slug%</code>, <code>%post_url%</code>, <code>%post_full_url%</code>, <code>%post_excerpt%</code>, <code>%post_tags%</code>, <code>%home_url%</code></p>
467
						</td>
468
					</tr>
469
					<tr valign="top">
470
						<th scope="row" width="100"><label><?php _e( 'Icon URL', 'jetpack' ); ?></label></th>
471
						<td>
472
							<input type="text" name="sharing_icon" id="new_sharing_icon" size="40" />
473
							<p><?php _e( 'Enter the URL of a 16x16px icon you want to use for this service.', 'jetpack' ); ?></p>
474
						</td>
475
					</tr>
476
					<tr valign="top" width="100">
477
						<th scope="row"></th>
478
						<td>
479
							<input type="submit" class="button-primary" value="<?php esc_attr_e( 'Create Share Button', 'jetpack' ); ?>" />
480
							<img src="<?php echo admin_url( 'images/loading.gif' ); ?>" width="16" height="16" alt="loading" style="vertical-align: middle; display: none" />
481
						</td>
482
					</tr>
483
484
					<?php
485
					/**
486
					 * Fires after the custom sharing service form
487
					 *
488
					 * @module sharedaddy
489
					 *
490
					 * @since 1.1.0
491
					 */
492
					do_action( 'sharing_new_service_form' );
493
					?>
494
				</tbody>
495
			</table>
496
497
		<?php
498
		/**
499
		 * Fires at the bottom of the admin sharing settings screen.
500
		 *
501
		 * @module sharedaddy
502
		 *
503
		 * @since 1.6.0
504
		 */
505
		do_action( 'post_admin_screen_sharing' );
506
		?>
507
508
				<div class="inerror" style="display: none; margin-top: 15px">
509
					<p><?php _e( 'An error occurred creating your new sharing service - please check you gave valid details.', 'jetpack' ); ?></p>
510
				</div>
511
512
			<input type="hidden" name="action" value="sharing_new_service" />
513
			<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-new_service' );?>" />
514
		</form>
515
	</div>
516
	</div>
517
518
	<?php endif; ?>
519
520
521
	</div>
522
523
	<script type="text/javascript">
524
		var sharing_loading_icon = '<?php echo esc_js( admin_url( '/images/loading.gif' ) ); ?>';
525
		<?php if ( isset( $_GET['create_new_service'] ) && 'true' == $_GET['create_new_service'] ) : ?>
526
		jQuery(document).ready(function() {
527
			// Prefill new service box and then open it
528
			jQuery( '#new_sharing_name' ).val( '<?php echo esc_js( $_GET['name'] ); ?>' );
529
			jQuery( '#new_sharing_url' ).val( '<?php echo esc_js( $_GET['url'] ); ?>' );
530
			jQuery( '#new_sharing_icon' ).val( '<?php echo esc_js( $_GET['icon'] ); ?>' );
531
			jQuery( '#add-a-new-service' ).click();
532
		});
533
		<?php endif; ?>
534
	</script>
535
<?php
536
	}
537
}
538
539
function sharing_admin_init() {
540
	global $sharing_admin;
541
542
	$sharing_admin = new Sharing_Admin();
543
}
544
545
add_action( 'init', 'sharing_admin_init' );
546