Skip to content

Commit

Permalink
Add a default blank template to be used (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
carstingaxion authored Feb 16, 2024
2 parents 0cb0ae6 + 6dbd1d9 commit 7a752e9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand Down
6 changes: 3 additions & 3 deletions inc/post-type-templates/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -38,7 +38,7 @@ function load(): void {
'templates' => [
'blank.php' => \_x( 'Blank', 'Template Title', 'figurentheater' ),
],
'path' => TEMPLATES_DIRECTORY,
'path' => Theming\DIRECTORY . TEMPLATES_DIRECTORY,
]
);

Expand Down Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions templates/post-type-templates/blank.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
/**
* Template Name: Blank
* Template Post Type: page
*
* @package figuren-theater/ft-theming
*/

0 comments on commit 7a752e9

Please sign in to comment.