-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwp_extension_manager.php
More file actions
83 lines (66 loc) · 1.73 KB
/
wp_extension_manager.php
File metadata and controls
83 lines (66 loc) · 1.73 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
<?php
/*
Plugin Name: Extension Manager
Plugin URI: -
Description: Plugin for tracking extension upgrades and creating of restoring points
Version: 0.1
Author: -
Author URI: -
*/
// define constants
define(EM_DIR_MAIN,WP_CONTENT_DIR.'/extension_updates');
define(EM_DIR_PLUGINS,WP_CONTENT_DIR.'/extension_updates/plugins');
include_once('PluginManager.php');
add_action('admin_menu', 'tp_add_tools_menu');
//add_action("pre_current_active_plugins",'empty_update_msg');
//add_action("in_plugin_update_message-txt-as-post/txtaspost.php",'test');
function empty_update_msg()
{
/* echo "<script language=\"javascript\">
jQuery(document).ready(function()
{
jQuery('.update-message a').each(function()
{
old_href = this.href;
this.href = old_href+'str'; // this is for a test only
});
});
</script>";
*/
}
function test()
{
echo 'test';
}
/**
* Main function. Adding item to the menu
*/
function tp_add_tools_menu()
{
add_submenu_page('tools.php', 'WP Extension Manager', 'WP Extension Manager', 10, basename(__FILE__), 'show_index_page');
add_action('activate_plugin','em_activate_plugin');
}
function em_activate_plugin( $plugin, $redirect = '', $network_wide = false )
{
create_restore_point($plugin);
}
function show_index_page()
{
echo '<h1>WP Extension Manager</h1>';
}
function create_restore_point($plugin)
{
$pm = new PluginManager($plugin);
$pm->createRestorePoint();
$plugin = $pm->getPlugin();
// log plugin activation
log_plugin_activation($plugin->Name);
}
function log_plugin_activation($log_message)
{
// log plugin activation
$fh = fopen(WP_CONTENT_DIR .'/plugins/wp_extension_manager/plugin_activation.log','a+');
fputs($fh,date('Y-m-d @ H:i:s').' '.$log_message."\n");
fclose($fh);
}
?>