Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update wp hooks dependency renamed wp 6.0 and aliases #37

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.json text eol=lf
17 changes: 15 additions & 2 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ protected static function loadStubbedHooks() : void {
return;
}

$wp_hooks_data_dir = self::getVendorDir( 'vendor/johnbillion/wp-hooks/hooks' );
$wp_hooks_data_dir = self::getVendorDir('vendor/wp-hooks/wordpress-core/hooks');

static::loadHooksFromFile( $wp_hooks_data_dir . '/actions.json' );
static::loadHooksFromFile( $wp_hooks_data_dir . '/filters.json' );
Expand Down Expand Up @@ -175,7 +175,20 @@ protected static function loadHooksFromFile( string $filepath ) : void {
// Must be done before parseString to avoid notice there.
$types = array_filter( $types );

static::registerHook( $hook['name'], array_map( [ Type::class, 'parseString' ], $types ), $hook['type'] );
// skip invalid ones
try {
$parsed_types = array_map( [ Type::class, 'parseString' ], $types );
} catch ( \Psalm\Exception\TypeParseTreeException $e ) {
continue;
}

static::registerHook( $hook['name'], $parsed_types, $hook['type'] );

if ( isset( $hook['aliases'] ) && is_array( $hook['aliases'] ) ) {
foreach ( $hook['aliases'] as $alias_name ) {
static::registerHook( $alias_name, $parsed_types, $hook['type'] );
}
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
],
"require": {
"ext-simplexml": "*",
"johnbillion/wp-hooks": "^0.8.0",
"php-stubs/wordpress-stubs": "^5.5",
"wp-hooks/wordpress-core": "^1.3.0",
"php-stubs/wordpress-stubs": "^6.0",
"php-stubs/wordpress-globals": "^0.2.0",
"php-stubs/wp-cli-stubs": "^2.5",
"php-stubs/wp-cli-stubs": "^2.7",
"vimeo/psalm": "^4"
},
"require-dev": {
Expand Down