-
Notifications
You must be signed in to change notification settings - Fork 0
chore: add tolkie hooks #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f9cdc65
chore: add tolkie hooks
FreakyWizard b3e4f52
chore: add tolkie component
FreakyWizard f880074
style: apply php-cs-fixer changes
yard-bot 59ddbda
chore: add config options
FreakyWizard e137aef
docs: usage
FreakyWizard 98f1ad7
chore: config options
FreakyWizard 060982c
docs: accurate example
FreakyWizard 35f85a3
fix: import component
FreakyWizard 2a5b02e
chore: pr comments and update docs
FreakyWizard 6e5dbc0
style: apply php-cs-fixer changes
yard-bot c2aa21d
fix: $block['attrs']['level'] needed otherwise adds after all headers…
FreakyWizard 625fd8e
style: apply php-cs-fixer changes
yard-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| <div class="tolkie-buttons-afterbegin"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Yard\Brave\Components; | ||
|
|
||
| use Illuminate\Contracts\View\Factory; | ||
| use Illuminate\View\Component; | ||
| use Illuminate\View\View; | ||
|
|
||
| class Tolkie extends Component | ||
| { | ||
| public function render(): Factory|View | ||
| { | ||
| return view('brave::components.tolkie'); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Yard\Brave\Hooks; | ||
|
|
||
| use Yard\Hook\Action; | ||
| use Yard\Hook\Filter; | ||
|
|
||
| class Tolkie | ||
| { | ||
| #[Action('wp_footer')] | ||
| public function addTolkieScript(): void | ||
| { | ||
| wp_print_script_tag([ | ||
| ...config('components.tolkie.html_attributes', [ | ||
| 'data-tolkie-state' => 'separateButtons', | ||
| ]), | ||
| 'class' => 'tolkieIntegrationScript', | ||
| 'id' => 'tolkie-script', | ||
| 'type' => 'module', | ||
| 'src' => 'https://app.tolkie.nl/', | ||
| 'crossorigin' => 'anonymous', | ||
| 'defer' => '', | ||
| 'data-tolkie-token' => config('components.tolkie.token'), | ||
| ]); | ||
| } | ||
|
|
||
| #[Filter('render_block_core/heading')] | ||
| #[Filter('render_block_core/post-title')] | ||
| public function addTolkieTag(string $content, array $block): string | ||
| { | ||
| if (config('components.tolkie.automatically_add_to_h1', true) && 1 === ($block['attrs']['level'] ?? 0)) { | ||
| $content .= '<div class="tolkie-buttons-afterbegin"></div>'; | ||
| } | ||
|
|
||
| return $content; | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
automaticallyAddToH1 => automatically_add_to_h1 👀
Kunnen we dit nog aanpassen met backwards compatibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Da was nie mijn aanpassing! Maar wel cool om dat voor Tolkie toe te voegen ja :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Die van readSpeaker pak ik op in een tweede pr