@atanas-dev Great work and thanks a lot for the framework. Looking forward to use it on my projects. Can somebody help me with why I am getting "Unknown named parameter $post_id" when post_id has been matched in web.php? Same for post_slug, post_status...
Error thrown with message "Unknown named parameter $post_id"
#20 Error in /Users/banestojanovic/Code/Manastiri/podmaine/wp-content/themes/podmaine/vendor/htmlburger/wpemerge/src/Kernels/HttpKernel.php:177
#19 call_user_func_array in /Users/banestojanovic/Code/Manastiri/podmaine/wp-content/themes/podmaine/vendor/htmlburger/wpemerge/src/Kernels/HttpKernel.php:177
#18 WPEmerge\Kernels\HttpKernel:executeHandler in /Users/banestojanovic/Code/Manastiri/podmaine/wp-content/themes/podmaine/vendor/htmlburger/wpemerge/src/Kernels/HttpKernel.php:205
#17 WPEmerge\Kernels\HttpKernel:WPEmerge\Kernels\{closure} in /Users/banestojanovic/Code/Manastiri/podmaine/wp-content/themes/podmaine/vendor/htmlburger/wpemerge/src/Middleware/ExecutesMiddlewareTrait.php:40
#16 WPEmerge\Kernels\HttpKernel:executeMiddleware in /Users/banestojanovic/Code/Manastiri/podmaine/wp-content/themes/podmaine/vendor/htmlburger/wpemerge/src/Middleware/ExecutesMiddlewareTrait.php:44
#15 WPEmerge\Kernels\HttpKernel:WPEmerge\Middleware\{closure} in /Users/banestojanovic/Code/Manastiri/podmaine/wp-content/themes/podmaine/vendor/htmlburger/wpemerge/src/Input/OldInputMiddleware.php:44
#14 WPEmerge\Input\OldInputMiddleware:handle in /Users/banestojanovic/Code/Manastiri/podmaine/wp-content/themes/podmaine/vendor/htmlburger/wpemerge/src/Middleware/ExecutesMiddlewareTrait.php:53
#13 call_user_func_array in /Users/banestojanovic/Code/Manastiri/podmaine/wp-content/themes/podmaine/vendor/htmlburger/wpemerge/src/Middleware/ExecutesMiddlewareTrait.php:53
#12 WPEmerge\Kernels\HttpKernel:executeMiddleware in /Users/banestojanovic/Code/Manastiri/podmaine/wp-content/themes/podmaine/vendor/htmlburger/wpemerge/src/Middleware/ExecutesMiddlewareTrait.php:44
#11 WPEmerge\Kernels\HttpKernel:WPEmerge\Middleware\{closure} in /Users/banestojanovic/Code/Manastiri/podmaine/wp-content/themes/podmaine/vendor/htmlburger/wpemerge/src/Flash/FlashMiddleware.php:40
#10 WPEmerge\Flash\FlashMiddleware:handle in /Users/banestojanovic/Code/Manastiri/podmaine/wp-content/themes/podmaine/vendor/htmlburger/wpemerge/src/Middleware/ExecutesMiddlewareTrait.php:53
#9 call_user_func_array in /Users/banestojanovic/Code/Manastiri/podmaine/wp-content/themes/podmaine/vendor/htmlburger/wpemerge/src/Middleware/ExecutesMiddlewareTrait.php:53
#8 WPEmerge\Kernels\HttpKernel:executeMiddleware in /Users/banestojanovic/Code/Manastiri/podmaine/wp-content/themes/podmaine/vendor/htmlburger/wpemerge/src/Kernels/HttpKernel.php:206
#7 WPEmerge\Kernels\HttpKernel:run in /Users/banestojanovic/Code/Manastiri/podmaine/wp-content/themes/podmaine/vendor/htmlburger/wpemerge/src/Kernels/HttpKernel.php:237
#6 WPEmerge\Kernels\HttpKernel:handle in /Users/banestojanovic/Code/Manastiri/podmaine/wp-content/themes/podmaine/vendor/htmlburger/wpemerge/src/Kernels/HttpKernel.php:332
#5 WPEmerge\Kernels\HttpKernel:filterTemplateInclude in /Users/banestojanovic/Code/Manastiri/podmaine/wp-includes/class-wp-hook.php:292
#4 WP_Hook:apply_filters in /Users/banestojanovic/Code/Manastiri/podmaine/wp-includes/plugin.php:212
#3 apply_filters in /Users/banestojanovic/Code/Manastiri/podmaine/wp-includes/template-loader.php:104
#2 require_once in /Users/banestojanovic/Code/Manastiri/podmaine/wp-blog-header.php:19
#1 require in /Users/banestojanovic/Code/Manastiri/podmaine/index.php:17
#0 require in /Users/banestojanovic/.composer/vendor/laravel/valet/server.php:219
@atanas-dev Hello Atanas, I can't get JSON responses to work for web request. The header is always empty. I debugged the entire HTTP Kernel.
For example:
App::json(['foo' => 'bar'])
renders correctly in the browser. But the header is empty. Ie content type is not set to application/json altought the kernel supposedly called `sentHeaders()``
add_menu_page
// This will not work
add_menu_page( 'test', 'test' , 'manage_options', 'test' );
// Forth parameter is optional in Wordpress but its needed to work correctly
add_menu_page( 'test', 'test' , 'manage_options','test', function () {
// Nothing.
});
The reason for this is that inside wp-admin/admin.php
Wordpress checks if there is a hook callback registered for the current plugin page. If no hook is present it takes a different path inside the gigantic if elseif
statement that wp-admin/admin.php
is.
Instead of dispatching the normal hooks wordpress then tries to load the content from a plugin file and if it cant find any matching file an error is thrown.
@atanas-dev Can you explain what is ment by this in the docs
"You should use query() on routes which do not match any valid WordPress URL or your WP Query will consider the request as a 404 - Not Found. You can find more information on this in the dedicated Query API blog post."
->query()
called on them because the conditions require the query to have been executed in order to match (i.e. you can't test against the current post id if the main query hasn't resolved what the current post is yet).
post_id
route looks like:App::route()->any()->where( 'post_id', get_option( 'my_special_page_id' ) )->handle( 'MyController::myMethod' );
is_404
I guess :D
the condition
\App::route()->get()->where( 'query_var', 's' )->handle( $handler );
Only matches default query vars defined in WP_QUERY right?
Something like this did not work for me for "non WP Urls".
https//example.com/page?foo='bar'
::routeUrl()
will work though, since reverse construction is not supported in FastRoute
@atanas-dev FastRoute is still maintained and in fact 2.0 is soon to be released. Nevertheless 1.3 is stable and feature complete. Lumen, Slim and other still use it.
I could not resist myself and got this done. I have a working version locally which works like this now: ( note that this is basically a complete rewrite of the router and condition factory. )
I assume performance will be a lot higher for sites with many routes but I dont have the time to benchmark things right now and Im also not that experienced in setting up proper benchmarking.
Ofc I dont have any expectations of this being merged ever ( required php 7.3 ) but Ill share you the repo if you want when Im done, maybe you ll find some ideas for WPEmerge aswell.
Right now I have a suggestion for you tho, maybe you overlooked this at first.
Whoops has an option to open files directly in the editor of your choice.
Its as simple as doing this.
$pretty_page_handler->setEditor('phpstorm');
Might be a nice addition, the value would then come from the user config of course
myapp_get_index_404_message()
but i'm struggling on how to detect a page that is not going through a page template, a page or anything from WP (since it's built by the controller...). anything i've tested so far works (is_page()
, is_page_template()
, is_archive()
, etc). any idea on how to intercept that? thanks :)