Skip to content
Open
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
6 changes: 3 additions & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
test:
uses: yardinternet/workflows/.github/workflows/run-laravel-testbench-tests.yml@main
with:
php-versions: '["8.1","8.2"]'
laravel-versions: '["10.*"]'
testbench-versions: '["8.*"]'
php-versions: '["8.2","8.3"]'
laravel-versions: '["12.*"]'
testbench-versions: '["10.*"]'
secrets: inherit
99 changes: 49 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@

An acorn package providing a "Query Block" for the Gutenberg editor.

## Requirements

- [Sage](https://github.com/roots/sage) >= 10.0
- [Acorn](https://github.com/roots/acorn) >= 4.0

## Installation

1. Add the following to the `repositories` section of your `composer.json`:
Expand All @@ -38,7 +33,8 @@ An acorn package providing a "Query Block" for the Gutenberg editor.

## Usage

When this package is installed, you can insert the “Berichtenlijst” block in the Gutenberg editor. This block lists a series of posts based on different filter settings in the admin.
When this package is installed, you can insert the “Berichtenlijst” block in the Gutenberg editor. This block lists a
series of posts based on different filter settings in the admin.

### Templates

Expand All @@ -50,7 +46,9 @@ A default template is included in the package. You can publish the template to y
wp acorn vendor:publish --provider="Yard\QueryBlock\QueryBlockServiceProvider"
```

This will copy the view default.php from this package into your project at `/sage/resources/views/vendor/yard-query-block/templates/default.blade.php`. You can now modify the default template as desired.
This will copy the view default.php from this package into your project at
`/sage/resources/views/vendor/yard-query-block/templates/default.blade.php`. You can now modify the default template as
desired.

#### Create Aditional Templates

Expand All @@ -71,7 +69,8 @@ Add the template name as a comment at the top of this template file like this:
@endphp
```

Now, you will be able to select the template from the editor. The name of the template is displayed using the value in your docblock.
Now, you will be able to select the template from the editor. The name of the template is displayed using the value in
your docblock.

## Hooks

Expand All @@ -85,15 +84,15 @@ Customize which controls are displayed in the block's inspector panel.
import { addFilter } from '@wordpress/hooks';

addFilter(
'yard.query-inspector-config',
'yard.query-inspector-config',
( config, attributes ) => {
return {
...config,
showPostTypeSelectControl: false,
showNumberOfPostsRangeControl: false,
};
}
'yard.query-inspector-config',
'yard.query-inspector-config',
(config, attributes) => {
return {
...config,
showPostTypeSelectControl: false,
showNumberOfPostsRangeControl: false,
};
}
);
```

Expand All @@ -105,16 +104,16 @@ Exclude specific post types from the list of available post types.
import { addFilter } from '@wordpress/hooks';

addFilter(
'yard.query-exclude-post-types',
'yard.query-exclude-post-types',
( excludedPostTypes ) => {
return [
...excludedPostTypes,
'healthcare-provider',
'location',
'page',
];
}
'yard.query-exclude-post-types',
'yard.query-exclude-post-types',
(excludedPostTypes) => {
return [
...excludedPostTypes,
'healthcare-provider',
'location',
'page',
];
}
);
```

Expand All @@ -126,11 +125,11 @@ Exclude specific taxonomies from the list of available taxonomies.
import { addFilter } from '@wordpress/hooks';

addFilter(
'yard.query-exclude-taxonomies',
'yard.query-exclude-taxonomies',
( excludedTaxonomies ) => {
return [ 'category', 'post_tag' ];
}
'yard.query-exclude-taxonomies',
'yard.query-exclude-taxonomies',
(excludedTaxonomies) => {
return ['category', 'post_tag'];
}
);
```

Expand All @@ -142,21 +141,21 @@ Customize the minimum and maximum value for the posts per page range.
import { addFilter } from '@wordpress/hooks';

addFilter(
'yard.query-max-number-of-posts',
'yard.query-max-number-of-posts',
(defaultMax, attributes) => {
const postTypeValues = attributes.postTypes?.map((type) => type.value) || [];
if (postTypeValues.includes('news')) {
return 5;
}

if (postTypeValues.includes('healthcare-provider')) {
return 2;
}

return defaultMax;
}
'yard.query-max-number-of-posts',
'yard.query-max-number-of-posts',
(defaultMax, attributes) => {
const postTypeValues = attributes.postTypes?.map((type) => type.value) || [];

if (postTypeValues.includes('news')) {
return 5;
}

if (postTypeValues.includes('healthcare-provider')) {
return 2;
}

return defaultMax;
}
);
```

Expand All @@ -168,9 +167,9 @@ Change the post type select control from multi to single select.
import { addFilter } from '@wordpress/hooks';

addFilter(
'yard.query-post-type-select-control-is-multi',
'yard.query-post-type-select-control-is-multi',
() => false
'yard.query-post-type-select-control-is-multi',
'yard.query-post-type-select-control-is-multi',
() => false
);
```

Expand Down
118 changes: 60 additions & 58 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,60 +1,62 @@
{
"name": "yard/query-block",
"type": "package",
"description": "A query block for the Gutenberg editor.",
"version": "1.0.14",
"license": "MIT",
"config": {
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"repositories": [
{
"type": "vcs",
"url": "git@github.com:yardinternet/yard-data.git"
}
],
"require": {
"illuminate/auth": "^10.48",
"jgrossi/corcel": "^7.0",
"php": "^8.1",
"spatie/laravel-package-tools": "^1.16",
"webmozart/assert": "^1.11",
"yard/data": "^1.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.57",
"larastan/larastan": "^2.0",
"orchestra/testbench": "^8.23",
"pestphp/pest": "^2.34",
"szepeviktor/phpstan-wordpress": "^1.0"
},
"autoload": {
"psr-4": {
"Yard\\QueryBlock\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Yard\\QueryBlock\\Tests\\": "tests/"
}
},
"scripts": {
"analyse": [
"sed -i -e 's#function __(#function ____(#' ./vendor/php-stubs/wordpress-stubs/wordpress-stubs.php",
"vendor/bin/phpstan analyse --debug --memory-limit 1G"
],
"format": "vendor/bin/php-cs-fixer fix",
"test": "vendor/bin/pest",
"test:coverage": "XDEBUG_MODE=coverage vendor/bin/pest --coverage"
},
"extra": {
"acorn": {
"providers": [
"Yard\\QueryBlock\\QueryBlockServiceProvider"
]
}
}
"name": "yard/query-block",
"type": "package",
"description": "A query block for the Gutenberg editor.",
"license": "MIT",
"config": {
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true
},
"platform": {
"php": "8.2"
}
},
"repositories": [
{
"type": "vcs",
"url": "git@github.com:yardinternet/yard-data.git"
}
],
"require": {
"php": "^8.2",
"jgrossi/corcel": "^9.0",
"roots/acorn": "^4.0|^5.0",
"spatie/laravel-package-tools": "^1.16",
"webmozart/assert": "^1.11",
"yard/data": "^1.0|dev-feat/acorn-5"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.57",
"larastan/larastan": "^3.0",
"orchestra/testbench": "^10.0",
"pestphp/pest": "^3.0",
"szepeviktor/phpstan-wordpress": "^2.0"
},
"autoload": {
"psr-4": {
"Yard\\QueryBlock\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Yard\\QueryBlock\\Tests\\": "tests/"
}
},
"scripts": {
"analyse": [
"sed -i -e 's#function __(#function ____(#' ./vendor/php-stubs/wordpress-stubs/wordpress-stubs.php",
"vendor/bin/phpstan analyse --debug --memory-limit 1G"
],
"format": "vendor/bin/php-cs-fixer fix",
"test": "vendor/bin/pest",
"test:coverage": "XDEBUG_MODE=coverage vendor/bin/pest --coverage"
},
"extra": {
"acorn": {
"providers": [
"Yard\\QueryBlock\\QueryBlockServiceProvider"
]
}
}
}
Loading