Skip to content

Instantly share code, notes, and snippets.

@epschmidt
Last active October 19, 2021 17:40
Show Gist options
  • Save epschmidt/3c9e7928d3ae4dacbf19 to your computer and use it in GitHub Desktop.
Save epschmidt/3c9e7928d3ae4dacbf19 to your computer and use it in GitHub Desktop.
Add a checkbox to the Add/Edit Link popup in WordPress to add a 'button' class to links. Replaces default wplink.js script. Current as of WordPress 4.2.4.
<?php
// adds checkbox to make link a button
function add_class_wplink() {
wp_deregister_script( 'wplink' );
wp_register_script( 'wplink', get_template_directory_uri() . '/js/admin/wplink.js', array( 'jquery', 'wpdialogs' ), false, 1 );
wp_localize_script( 'wplink', 'wpLinkL10n', array(
'title' => __('Insert/edit link'),
'update' => __('Update'),
'save' => __('Add Link'),
'noTitle' => __('(no title)'),
'noMatchesFound' => __('No matches found.')
) );
}
add_action( 'admin_enqueue_scripts', 'add_class_wplink', 999 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment