Skip to content

Commit 7cd0f8c

Browse files
committed
✨ Fixes missing route load acction for custom route
1 parent b99f416 commit 7cd0f8c

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/Console/bin/bones

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ namespace Bones {
727727
define('WPBONES_MINIMAL_PHP_VERSION', '7.4');
728728

729729
/* MARK: The WP Bones command line version. */
730-
define('WPBONES_COMMAND_LINE_VERSION', '1.9.4');
730+
define('WPBONES_COMMAND_LINE_VERSION', '1.9.6');
731731

732732
use Bones\SemVer\Exceptions\InvalidVersionException;
733733
use Bones\SemVer\Version;

src/Routing/AdminRouteProvider.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
}
88

99
use WPKirk\WPBones\Support\ServiceProvider;
10+
use WPKirk\WPBones\Support\Str;
1011

1112
/**
1213
* Class AdminRouteProvider
@@ -45,6 +46,17 @@ function () use ($page) {
4546
);
4647
});
4748

49+
if (isset($page['route']['load'])) {
50+
[$controller, $method] = Str::parseCallback($page['route']['load']);
51+
52+
add_action("load-toplevel_page_{$page_slug}", function () use ($controller, $method) {
53+
$className = "WPKirk\\Http\\Controllers\\{$controller}";
54+
$instance = new $className();
55+
56+
return $instance->{$method}();
57+
});
58+
}
59+
4860
add_action($hookName, $hook);
4961

5062
$_registered_pages[$hookName] = true;

0 commit comments

Comments
 (0)