Closed erezmus closed 7 years ago
Will test it and let you know. Weird that it's not called. At which line the issue is?
line 162 of functions.php
Ok thanks. I'll check for this. Can you paste your code for your rewrite rules and custom post type so I can replicate the issue?
In resources/actions.php
add_action('init', function() {
PostType::make('news', 'News', 'News')->set([
'public' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'show_ui' => true,
'query_var' => true,
'menu_position' => 8,
'rewrite' => ['slug' => 'news', 'with_front' => false],
'has_archive' => 'news',
'capability_type' => 'post',
'hierarchical' => false,
'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt')
]);
});
I haven't yet looked into this but you can remove your call to add_action
in order to build your custom post type. The class handle this for you, which saves some lines of code ;)
remove the add_action gives me Fatal error: Class 'PostType' not found
Hmm. Are you running the latest release version? or do you use the dev-master
version? Check the latest bootstrap/start.php
file of the themosis/theme and update yours. This should not triggers a fatal error.
yep latest one, and have pretty much the same theme bootstrap/start.php
as the themosis/theme. Is it because its in in resources/admin and they get included before the after_setup_theme. Its in that hook that the frameworks's bootstrap/start.php
adds the facades as class aliases?
Yep it's in that hook that class aliases are defined for the facades. This means that you can't use short class name before the after_setup_theme
hook. Always use full classnames for configuration and bootstrapping.
Is there a reason why they are defined in that hook?
Yes it's the only way I found to allow developers to override/add custom aliases into their plugins or themes.
what about having them all in a config file (e.g. config/aliases.config.php
or even in config/application.config.php
, the same way that is done in laravel's config/app.php ? That way they just modify or add to the array?
I'll say I'm open to suggestions because I'm struggling to allow plugins define their custom aliases. I suppose it's not something I should allow as it may creates conflicts between plugins. Perhaps aliases can only be defined when working in the theme where we gather all the data to build our views. Seems logical for me as I'm writing.
When doing the command wp rewrite flush --hard, rewrite rules for my custom post types defined in resources/actions.php where not being generated. When going to backend of the WordPress install to Settings \ Permalinks, they did get generated.
I traced it to a problem in the theme's functions.php at the line:
For some reason this seems to include the bootstrap/start.php file in the themosis framework and not the theme's bootstrap/start.php when running in wp cli.
@jlambe do you agree? I can do a PR, just want to make sure its not just me