Skip to content

Commit

Permalink
Remove unused JS logic in email sharing (#6339)
Browse files Browse the repository at this point in the history
* Remove unused JS logic

Fixes #1223

* Print inline scripts after WP is done with footer scripts

Ensures that dependencies are met.
  • Loading branch information
kasparsd authored and dereksmart committed Feb 10, 2017
1 parent 4d148b9 commit bba03ce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 7 additions & 0 deletions modules/sharedaddy/sharing-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,9 @@ function sharing_add_footer() {
);
wp_localize_script( 'sharing-js', 'sharing_js_options', $sharing_js_options);
}
}

function sharing_add_footer_scripts_inline() {
$sharer = new Sharing_Service();
$enabled = $sharer->get_blog_services();
foreach ( array_merge( $enabled['visible'], $enabled['hidden'] ) AS $service ) {
Expand Down Expand Up @@ -773,7 +775,12 @@ function sharing_display( $text = '', $echo = false ) {
$ver = '20141212';
}
wp_register_script( 'sharing-js', plugin_dir_url( __FILE__ ).'sharing.js', array( 'jquery' ), $ver );

// Enqueue scripts for the footer
add_action( 'wp_footer', 'sharing_add_footer' );

// Print inline scripts that depend on jQuery
add_action( 'wp_footer', 'sharing_add_footer_scripts_inline', 25 );
}
}

Expand Down
1 change: 0 additions & 1 deletion modules/sharedaddy/sharing-sources.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,6 @@ public function display_footer() {

<?php endif; ?>
<input type="text" id="jetpack-source_f_name" name="source_f_name" class="input" value="" size="25" autocomplete="off" />
<script>jQuery( document ).ready( function(){ document.getElementById('jetpack-source_f_name').value = '' });</script>
<?php
/**
* Fires when the Email sharing dialog is loaded.
Expand Down

0 comments on commit bba03ce

Please sign in to comment.