This repository has been archived by the owner on Mar 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathacf-cleaner.php
64 lines (40 loc) · 1.52 KB
/
acf-cleaner.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/*
Plugin Name: ACF Cleaner
Plugin URI: https://github.com/1n3JgKl9pQ6cUMrW/acf-cleaner
Description: Remove empty and orphaned ACF entries.
Version: 1.4.2
Author: 1n3JgKl9pQ6cUMrW
Author URI: https://github.com/1n3JgKl9pQ6cUMrW/
*/
add_action('admin_menu', 'acf_cleaner_admin_menu');
define('ACF_CLEANER_PAGE', plugin_basename(dirname(__FILE__)) . '/acf-cleaner-admin.php');
function acf_cleaner_admin_menu() {
add_management_page(__('ACF Cleaner | Manage', 'acf_cleaner'),
__('ACF Cleaner', 'acf_cleaner'),
'manage_options',
ACF_CLEANER_PAGE,
'');
}
add_filter('plugin_row_meta', 'acf_cleaner_meta_links', 10, 2);
add_filter('plugin_action_links', 'acf_cleaner_manage_link', 10, 2);
function acf_cleaner_manage_link($links, $file) {
static $this_plugin;
if (!$this_plugin){
$this_plugin = plugin_basename(__FILE__);
}
if ($file == $this_plugin) {
$settings_link = '<a href="tools.php?page=' . ACF_CLEANER_PAGE . '" title="' . __('Use this plugin', 'acf_cleaner') . '">' . __('Manage', 'acf_cleaner') . '</a>';
array_unshift($links, $settings_link);
}
return $links;
}
function acf_cleaner_meta_links($links, $file) {
$plugin = plugin_basename(__FILE__);
if ($file == $plugin) {
$links[] = '<a href="tools.php?page=' . ACF_CLEANER_PAGE . '" title="' . __('Use this plugin', 'acf_cleaner') . '">' . __('Manage', 'acf_cleaner') . '</a>';
return $links;
}
return $links;
}
?>