sharing.php 20 KB

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