Skip to content

Instantly share code, notes, and snippets.

@garretthyder
Last active March 1, 2018 06:06
Show Gist options
  • Save garretthyder/13793e706fa01f7b14c7d0a94429c810 to your computer and use it in GitHub Desktop.
Save garretthyder/13793e706fa01f7b14c7d0a94429c810 to your computer and use it in GitHub Desktop.
Yoast SEO - Copy from Snippet
<?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' );
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