diff --git a/README.md b/README.md index 4a77604..6f551f5 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,20 @@ Thoose are completely managed by code and lack of their typical UI. Accompaniying the core functionality of the mentioned plugins, theese **best practices** are included with this package. +- [x] Allow any post type to use one or more templates, independently from the theme. This is enabled by default for the `page` post type by using + ```php + add_post_type_support( + 'page', + 'post-type-templates', + [ + 'templates' => [ + 'blank.php'=>'A blank canvas' + ], + 'path'=>'ABSPATH_TO_TEMPLATE_DIRECTORY' + ] + ); + ``` + - [x] Allow third-party scripts to be loaded either `defer`ed or `async` via a filter or a URL#hash. - [x] Remove jquery 'MIGRATE' console message from frontend. - [x] Deliver our figuren.theater favicon as fallback, if non is set diff --git a/composer.json b/composer.json index 81f1791..f481b00 100644 --- a/composer.json +++ b/composer.json @@ -47,6 +47,7 @@ "inc/" ], "files": [ + "inc/post-type-templates/namespace.php", "inc/theming/defer-async-loader.php", "inc/theming/favicon-fallback.php", "inc/theming/no-jquery-migrate.php", @@ -58,9 +59,9 @@ "config": { "allow-plugins": { "composer/installers": true, - "phpstan/extension-installer": true, "dealerdirect/phpcodesniffer-composer-installer": true, - "ergebnis/composer-normalize": true + "ergebnis/composer-normalize": true, + "phpstan/extension-installer": true } }, "extra": { diff --git a/inc/post-type-templates/namespace.php b/inc/post-type-templates/namespace.php index 416f608..46fb106 100644 --- a/inc/post-type-templates/namespace.php +++ b/inc/post-type-templates/namespace.php @@ -11,7 +11,7 @@ use function add_action; const PT_SUPPORT = 'post-type-templates'; -const TEMPLATES_DIRECTORY = Theming\DIRECTORY . '/templates/post-type-templates/'; +const TEMPLATES_DIRECTORY = '/templates/post-type-templates/'; /** * Bootstrap module, when enabled. @@ -38,7 +38,7 @@ function load(): void { 'templates' => [ 'blank.php' => \_x( 'Blank', 'Template Title', 'figurentheater' ), ], - 'path' => TEMPLATES_DIRECTORY, + 'path' => Theming\DIRECTORY . TEMPLATES_DIRECTORY, ] ); @@ -71,7 +71,7 @@ function register_post_type_template( string $post_type ): void { // Try to provide a fallback, if no path was given. // This allows other ft-modules to call add_post_type_support // with just the name of the template from the ft-theming module, that should be used. - $post_type_supports['path'] = TEMPLATES_DIRECTORY; + $post_type_supports['path'] = Theming\DIRECTORY . TEMPLATES_DIRECTORY; } // Checks for file existence are done inside the Loader class. diff --git a/templates/post-type-templates/blank.php b/templates/post-type-templates/blank.php new file mode 100644 index 0000000..03ba970 --- /dev/null +++ b/templates/post-type-templates/blank.php @@ -0,0 +1,7 @@ +