-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathclassicpress-directory-integration.php
executable file
·86 lines (71 loc) · 3.17 KB
/
classicpress-directory-integration.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* -----------------------------------------------------------------------------
* Plugin Name: ClassicPress Directory Integration
* Description: Install and update plugins and themes from ClassicPress directory.
* Version: 1.1.2
* Author: ClassicPress Contributors
* Author URI: https://www.classicpress.net
* Plugin URI: https://www.classicpress.net
* Text Domain: classicpress-directory-integration
* Domain Path: /languages
* Requires PHP: 7.4
* Requires CP: 2.0
* -----------------------------------------------------------------------------
* This is free software released under the terms of the General Public License,
* version 2, or later. It is distributed WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Full
* text of the license is available at https://www.gnu.org/licenses/gpl-2.0.txt.
* -----------------------------------------------------------------------------
*/
// Declare the namespace.
namespace ClassicPress\Directory;
// Prevent direct access.
if (!defined('ABSPATH')) {
die();
}
// Bail if on WordPress
if(!function_exists('classicpress_version')) {
add_action('admin_init', 'ClassicPress\Directory\deactivate_plugin_now');
add_action('admin_notices', 'ClassicPress\Directory\error_is_wp');
unset($_GET['activate']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
return;
}
function deactivate_plugin_now() {
if (is_plugin_active('classicpress-directory-integration/classicpress-directory-integration.php')) {
deactivate_plugins('classicpress-directory-integration/classicpress-directory-integration.php');
}
}
function error_is_wp () {
$class = 'notice notice-error';
$message = __('ClassicPress Directory integration is a plugin meant to only work on ClassicPress sites.', 'classicpress-directory-integration');
printf('<div class="%1$s"><p>%2$s</p></div>', esc_attr($class), esc_html($message));
}
const DB_VERSION = 1;
// Load non namespaced constants and functions
require_once 'includes/constants.php';
require_once 'includes/functions.php';
// Load Helpers trait.
require_once 'classes/Helpers.trait.php';
// Load Plugin Update functionality class.
require_once 'classes/PluginUpdate.class.php';
$plugin_update = new PluginUpdate();
// Load Plugin Install functionality class.
require_once 'classes/PluginInstall.class.php';
$plugin_install = new PluginInstall();
// Load Theme Update functionality class.
require_once 'classes/ThemeUpdate.class.php';
$theme_update = new ThemeUpdate();
// Load Theme Install functionality class.
require_once 'classes/ThemeInstall.class.php';
$theme_install = new ThemeInstall();
// Register text domain
function register_text_domain() {
load_plugin_textdomain('classicpress-directory-integration', false, dirname(plugin_basename(__FILE__)).'/languages');
}
add_action('plugins_loaded', '\ClassicPress\Directory\register_text_domain');
// Add commands to WP-CLI
require_once 'classes/WPCLI.class.php';
if (defined('WP_CLI') && WP_CLI) {
\WP_CLI::add_command('cpdi', '\ClassicPress\Directory\CPDICLI');
}