Completed
Push — add/changelog-62 ( 9977bb...d371c2 )
by
unknown
10:21
created

avoid-plugin-deletion.php ➔ disable_plugin_deletion()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 9
nc 2
nop 4
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/*
4
Plugin Name: Remove delete link for Jetpack
5
Description: Removes the Delete link from your plugins list for the current Jetpack directory
6
Version: 1.0
7
Author: Automattic
8
Author URI: http://automattic.com/
9
*/
10
11
/**
12
 * avoid-plugin-deletion.php
13
 *
14
 * This file contains a hook that removes the Delete link from your plugins list for the current Jetpack directory.
15
 *
16
 * It was added because the effect of being able to delete your local development directory from WordPress is catastrophic and you can lose
17
 * your git history in the process.
18
 */
19
add_filter( 'plugin_action_links', 'disable_plugin_deletion', 10, 4 );
20
21
function disable_plugin_deletion( $actions, $plugin_file, $plugin_data, $context ) {
22
23
	// Remove delete link for important plugins
24
	if (
25
		array_key_exists( 'delete', $actions ) &&
26
		in_array(
27
			$plugin_file,
28
			array(
29
				'jetpack/jetpack.php',
30
			)
31
		)
32
	) {
33
		unset( $actions['delete'] );
34
	}
35
	return $actions;
36
}
37