-
Notifications
You must be signed in to change notification settings - Fork 1
/
gatherpress-alpha.php
94 lines (86 loc) · 2.85 KB
/
gatherpress-alpha.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
87
88
89
90
91
92
93
94
<?php
/**
* Plugin Name: GatherPress Alpha
* Plugin URI: https://gatherpress.org/
* Description: Powering Communities with WordPress.
* Author: The GatherPress Community
* Author URI: https://gatherpress.org/
* Version: 0.31.0
* Requires PHP: 7.4
* Text Domain: gatherpress-alpha
* License: GPLv2 or later (license.txt)
*
* @package GatherPress_Alpha
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
// Constants.
define( 'GATHERPRESS_ALPHA_VERSION', current( get_file_data( __FILE__, array( 'Version' ), 'plugin' ) ) );
define( 'GATHERPRESS_ALPHA_CORE_PATH', __DIR__ );
/**
* Adds the GatherPress_Alpha namespace to the autoloader.
*
* This function hooks into the 'gatherpress_autoloader' filter and adds the
* GatherPress_Alpha namespace to the list of namespaces with its core path.
*
* @param array $namespace An associative array of namespaces and their paths.
* @return array Modified array of namespaces and their paths.
*/
function gatherpress_alpha_autoloader( array $namespace ): array {
$namespace['GatherPress_Alpha'] = GATHERPRESS_ALPHA_CORE_PATH;
return $namespace;
}
add_filter( 'gatherpress_autoloader', 'gatherpress_alpha_autoloader' );
/**
* Displays an error notice if GatherPress and GatherPress Alpha versions do not match.
*
* This function outputs an error notice in the WordPress admin area, indicating
* that the versions of GatherPress and GatherPress Alpha must be the same.
*
* @return void
*/
function gatherpress_alpha_version_notice(): void {
?>
<div class="notice notice-error">
<p>
<?php esc_html_e( 'GatherPress and GatherPress Alpha must be the same version.', 'gatherpress-alpha' ); ?>
</p>
</div>
<?php
}
/**
* Displays an error notice indicating GatherPress is not installed.
*
* This function outputs an error notice in the WordPress admin area when
* GatherPress is not detected as installed, prompting users to install it.
*
* @return void
*/
function gatherpress_alpha_not_installed(): void {
?>
<div class="notice notice-error">
<p>
<?php esc_html_e( 'GatherPress is not installed.', 'gatherpress-alpha' ); ?>
</p>
</div>
<?php
}
/**
* Initializes the GatherPress Alpha setup.
*
* This function hooks into the 'plugins_loaded' action to ensure that
* the GatherPress_Alpha\Setup instance is created once all plugins are loaded,
* only if the GatherPress plugin is active.
*
* @return void
*/
function gatherpress_alpha_setup(): void {
if ( ! defined( 'GATHERPRESS_VERSION' ) ) {
add_action( 'admin_notices', 'gatherpress_alpha_not_installed' );
} elseif ( defined( 'GATHERPRESS_VERSION' ) && GATHERPRESS_VERSION !== GATHERPRESS_ALPHA_VERSION ) {
add_action( 'admin_notices', 'gatherpress_alpha_version_notice' );
} else {
GatherPress_Alpha\Setup::get_instance();
}
}
add_action( 'plugins_loaded', 'gatherpress_alpha_setup' );