forked from Exygy/re-slug
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathre-slug.php
25 lines (21 loc) · 899 Bytes
/
re-slug.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
/*
Plugin Name: Re-slug Updated
Plugin URI: https://github.com/lukecav/re-slug
Description: Regenerate the post permalink after changing the title.
Author: Luke Cavanagh
Author URI: https://profiles.wordpress.org/lukecavanagh
Version: 1.1
*/
function add_reslug_button ($return) {
// Add Re-slug button after Edit buton
$return = str_replace('Edit</button>', 'Edit</button> <button type="button" id="re-slug" class="edit-slug button button-small hide-if-no-js" style="display:inherit;"><a href="#re-slug">Re-slug</a></button>', $return);
return $return;
}
add_filter( 'get_sample_permalink_html', 'add_reslug_button', 10, 1 );
function enqueue_reslug_script($hook) {
if( 'post.php' != $hook && 'post-new.php' != $hook )
return;
wp_enqueue_script( 'reslug', plugin_dir_url( __FILE__ ) . '/re-slug.js' );
}
add_action( 'admin_enqueue_scripts', 'enqueue_reslug_script' );