Skip to content

Commit e332b9a

Browse files
authored
Merge pull request #4 from alleyinteractive/fix/undefined
Make sure variable is defined
2 parents 921c8d4 + a421909 commit e332b9a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/class-path-dispatch.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
namespace WP_Path_Dispatch;
1010

11+
use WP_Query;
12+
1113
/**
1214
* Path Dispatch
1315
*/
@@ -190,16 +192,19 @@ public function add_rewrite_rules() {
190192
* Trigger an action when a dispatched path is requested. Also, potentially load
191193
* a template if that was set.
192194
*
193-
* @param array $query Dispatch query.
195+
* @param WP_Query $query The WP_Query instance.
194196
*/
195197
public function dispatch_path( &$query ) {
196198
$path = get_query_var( 'dispatch' );
197199
if ( $query->is_main_query() && $path ) {
200+
$args = [];
201+
198202
if ( ! empty( $this->basic_paths[ $path ] ) ) {
199203
$args = $this->basic_paths[ $path ];
200204
} elseif ( ! empty( $this->rewrite_paths[ $path ] ) ) {
201205
$args = $this->rewrite_paths[ $path ];
202206
}
207+
203208
if ( empty( $args['action'] ) ) {
204209
do_action( 'dispatch_path_' . $path, $args ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
205210
} else {

0 commit comments

Comments
 (0)