-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisable-auto-updates.php
More file actions
executable file
·127 lines (94 loc) · 4.04 KB
/
disable-auto-updates.php
File metadata and controls
executable file
·127 lines (94 loc) · 4.04 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
/*
Plugin Name: Disable Auto Updates
Plugin URI: http://exeebit.com/wordpress-plugin/disable-automatic-updates
Description: A simple plugin to disable plugin, theme or core automatic updates
Version: 1.4
Author: Exeebit
Author URI: http://exeebit.com
License: GPLv3
*/
/**
*
* @package dau
*
*/
defined('ABSPATH') or die('Unauthorized Access');
if(!class_exists('Da_updates')){
class Da_updates{
public $dau_dir = WP_CONTENT_DIR . '/uploads/disable-auto-updates';
public function register() {
add_action('admin_menu', array($this, 'add_admin_pages'));
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
add_filter('clean_url', [$this, 'script_async'], 11, 1);
add_filter("plugin_row_meta", [$this, "meta"], 10, 2);
add_filter( 'plugin_action_links', [$this, 'ads_action_links'], 10, 5 );
// add_filter( 'plugin_auto_update_setting_html', [ $this, 'replace_auto_update_text' ], 10, 2 );
}
public function add_admin_pages() {
add_submenu_page('tools.php', 'Disable Auto Updates', 'Disable Auto Updates', 'manage_options', 'disable-auto-updates', [$this, 'view']);
if(file_exists("$this->dau_dir/disable-all.php") || file_exists("$this->dau_dir/hide-notification.php") || file_exists("$this->dau_dir/disable-core.php") && file_exists("$this->dau_dir/disable-theme.php") && file_exists("$this->dau_dir/disable-plugin.php")) {
remove_submenu_page( 'index.php', 'update-core.php');
}
}
public function view() {
require_once plugin_dir_path( __FILE__ ) . 'view/view.php';
}
public function activate() {
flush_rewrite_rules();
}
public function deactivate() {
flush_rewrite_rules();
}
public function enqueue() {
wp_enqueue_style('dau-plugin', plugins_url( 'css/styles.css', __FILE__ ));
wp_enqueue_script('dau-plugin', plugin_dir_url(__FILE__) . 'js/scripts.min.js#async');
}
public function script_async($url) {
if(strpos($url, '#async') === false) {
return $url;
} else {
return str_replace('#async', '', $url) . "' async='async";
}
}
public function footer_notice(){
echo '<span id="footer-thankyou">Thank you for using <a href="https://exeebit.com">Exeebit</a>\'s product. <a href="https://www.paypal.com/donate?hosted_button_id=LV33MVDQUBSYY" target="_blank">Buy Me a Coffee <span style="color: red">❤</span></a></span>';
}
public function thankyou() {
add_filter("admin_footer_text", [$this, 'footer_notice']);
}
public function meta($links = [], $file = "") {
if(strpos($file, "disable-auto-updates/disable-auto-updates.php") !== false) {
$new_link = [
"donation" => '<a href="https://www.paypal.com/donate?hosted_button_id=LV33MVDQUBSYY" target="_blank">Buy Me a Coffee <span style="color: red">❤</span></a>'
];
$links = array_merge($links, $new_link);
}
return $links;
}
public function replace_auto_update_text() {
return "Auto update has been disabled by <a href='https://wordpress.org/plugins/disable-auto-updates'>Disable Auto Updates</a>";
}
public function ads_action_links( $links, $plugin_file ) {
$plugin = plugin_basename( __FILE__ );
if($plugin === $plugin_file) {
$ads_links = [
'<a href="' . admin_url( 'tools.php?page=disable-auto-updates' ) . '">Settings</a>',
];
$links = array_merge($ads_links, $links);
}
return $links;
}
}
if(class_exists( 'Da_updates' )) $disable_auto_updates = new Da_updates();
else die('Plugin internal code conflict');
$disable_auto_updates->register();
register_activation_hook(__FILE__, [$disable_auto_updates, 'activate']);
register_deactivation_hook(__FILE__, [$disable_auto_updates, 'deactivate']);
$dau_services = ['disable-all', 'disable-plugin', 'disable-theme', 'disable-core', 'disable-admin-notice', 'hide-notification'];
foreach ($dau_services as $service) {
if(file_exists("$disable_auto_updates->dau_dir/$service.php")) {
include_once "$disable_auto_updates->dau_dir/$service.php";
}
}
}