-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactivate_plugin.php
More file actions
60 lines (54 loc) · 1.85 KB
/
activate_plugin.php
File metadata and controls
60 lines (54 loc) · 1.85 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
<?php
// Simple script to activate the SMO Social plugin
// Auto-detect WordPress installation
$possible_paths = [
'./wp-load.php', // Current directory
'../wp-load.php', // Parent directory
'../../wp-load.php', // Two levels up
dirname(__FILE__) . '/wp-load.php', // Same directory as this script
];
$wordpress_loaded = false;
foreach ($possible_paths as $path) {
if (file_exists($path)) {
define('WP_USE_THEMES', false);
require_once $path;
$wordpress_loaded = true;
break;
}
}
if (!$wordpress_loaded) {
die('Error: WordPress not found. Please run this script from your WordPress root directory.');
}
// Simulate plugin activation by calling the activation hook directly
$possible_plugin_paths = [
'./wp-content/plugins/smo-social/smo-social.php',
'../wp-content/plugins/smo-social/smo-social.php',
'../../wp-content/plugins/smo-social/smo-social.php',
dirname(__FILE__) . '/wp-content/plugins/smo-social/smo-social.php',
ABSPATH . 'wp-content/plugins/smo-social/smo-social.php'
];
$plugin_file = null;
foreach ($possible_plugin_paths as $path) {
if (file_exists($path)) {
$plugin_file = $path;
break;
}
}
if ($plugin_file && file_exists($plugin_file)) {
try {
// Include the plugin file
require_once $plugin_file;
// Call the activation function if it exists
if (function_exists('smo_social_activate')) {
smo_social_activate();
echo 'Plugin activated successfully!';
} else {
echo 'Activation function not found.';
}
} catch (Exception $e) {
echo 'Plugin activation failed: ' . $e->getMessage();
}
} else {
echo 'Plugin file not found. Please ensure the plugin is uploaded to wp-content/plugins/smo-social/ directory.';
}
?>