-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathphel-wp-plugin.php
More file actions
executable file
·38 lines (31 loc) · 1.21 KB
/
phel-wp-plugin.php
File metadata and controls
executable file
·38 lines (31 loc) · 1.21 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
<?php
/*
Plugin Name: Phel Demo Plugin
Description: Adds admin widget printing some content with Phel
Version: 0.2
Author: Jarkko Saltiola & contributors
Author URI: https://codeberg.org/jasalt
*/
use Phel\Phel;
$projectRootDir = __DIR__ . '/';
require $projectRootDir . 'vendor/autoload.php';
if (isset($PHP_SELF) && $PHP_SELF !== "./vendor/bin/phel"){
// Initialize Phel environment in regular WP plugin web request context.
// This can be also narrowed to only specific routes or conditions to avoid
// it's runtime overhead where it's not needed.
Phel::run($projectRootDir, 'phel-wp-plugin\main');
} else {
// Don't re-initialize Phel or run main namespace outside regular web request
// context e.g. when starting REPL session or running as WP-CLI command.
}
/*
* Register WP-CLI command 'wp phel' running Phel namespace at `src/cli.phel`
* https://make.wordpress.org/cli/handbook/guides/commands-cookbook/
*/
// TODO fix & re-enable for podman
// WP_CLI::add_command( 'phel',
// function ( $args ){
// $projectRootDir = __DIR__ . '/';
// Phel::run($projectRootDir, 'phel-wp-plugin\cli');
// WP_CLI::success( "done!" );
// }, ['shortdesc' => 'Runs Phel code as WP-CLI command']);