Last active
March 1, 2018 06:06
-
-
Save garretthyder/13793e706fa01f7b14c7d0a94429c810 to your computer and use it in GitHub Desktop.
Yoast SEO - Copy from Snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function admin_scripts() { | |
// Adding Yoast Copy from Original Script | |
wp_register_script( 'yoastcopy-js', get_template_directory_uri() . '/assets/js/yoastcopy.js', array( 'jquery' ), '0.0.1', true ); | |
wp_enqueue_script('yoastcopy-js'); | |
} | |
add_action( 'admin_enqueue_scripts', 'admin_scripts' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($) { | |
$(document).on('click', '.snippet-editor__edit-button', function() { | |
$('.snippet-editor__title').before('<a href="#" class="snippet-editor__title_copy">Copy from Snippet</a>'); | |
$('.snippet-editor__meta-description').before('<a href="#" class="snippet-editor__meta-description_copy">Copy from Snippet</a>'); | |
}); | |
$(document).on('click', '.snippet-editor__title_copy', function(e) { | |
e.preventDefault(); | |
$('.snippet-editor__title').val($('#snippet_title').text()); | |
}); | |
$(document).on('click', '.snippet-editor__meta-description_copy', function(e) { | |
e.preventDefault(); | |
$('.snippet-editor__meta-description').val($('#snippet_meta').text()); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment