-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample-plugin.php
51 lines (46 loc) · 1.4 KB
/
sample-plugin.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
<?php
/**
* Plugin Name: Sample Plugin
* Plugin URI: pluginade.com
* Description: A sample plugin which demonstrates how to build a plugin with Pluginade.
* Version: 0.0.0
* Author: Pluginade
* Text Domain: sample-plugin
* Domain Path: languages
* License: GPLv2
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Requires at least: 6.0
* Requires PHP: 7.4
* Network:
* Update URI:
* Namespace: SamplePlugin
*
* @package pluginade-sample
*/
namespace SamplePlugin;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Automatically include wp modules, which are in the "wp-modules" directory.
*
* @return void
*/
function include_custom_modules() {
$wp_modules = glob( plugin_dir_path( __FILE__ ) . 'wp-modules*/*' );
foreach ( $wp_modules as $wp_module ) {
$module_name = basename( $wp_module );
$filename = $module_name . '.php';
$filepath = $wp_module . '/' . $filename;
if ( is_readable( $filepath ) ) {
// If the module data exists, load it.
require $filepath;
} else {
// Translators: The name of the module, and the filename that needs to exist inside that module.
echo esc_html( sprintf( __( 'The module called "%1$s" has a problem. It needs a file called "%2$s" to exist in its root directory.', 'sample-plugin' ), $module_name, $filename ) );
exit;
}
}
}
add_action( 'plugins_loaded', __NAMESPACE__ . '\include_custom_modules' );