-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add Developer Actions and Filters #766
base: develop
Are you sure you want to change the base?
Add Developer Actions and Filters #766
Conversation
New Action: `syntax_highlighting_code_block_boot`. This action is run post boot after the `plugins_loaded` action has been executed. This is useful for letting others know when the plugin has finished its boot process in order to modify any early actions and filters the plugin uses.
…highlighting_code_block_injected_markup New filter: `syntax_highlighting_code_block_transient_key` - This is for filtering the language param that's returned. See: westonruter#191 New filter: `syntax_highlighting_code_block_injected_markup` - This is for being able to modify the output before its returned. This is to help those who want to extend the markup or introduce their own.
New action: `syntax_highlighting_code_block_highlighter_init` - Fires in the `render_block` function after the highlighter has been initialized. Helps fix: westonruter#191
…nguage names. Filter: `syntax_highlighting_code_block_language_names` - Resolves issue: westonruter#488
Filter `syntax_highlighting_code_block_injected_markup` is added to the output for the highlighted portion.
Filter: `syntaxHighlightingCodeBlockAttributes` allows you to set defaults for the code block.
Filter `syntax_highlighting_code_block_pre_start_tag` is for adding markup to pre tag and honoring block alignment.
Filter `syntax_highlighting_code_block_code_classes` allows you to add custom classes to the `code` element.
Remove filter `syntax_highlighting_code_block_pre_start_tag` as pre tag is not designed to have extra markup injected.
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.
Thanks for the PR! Could you surface the commit messages in which you explain the reasons for the new hooks to be PR description? This will make sure they aren't buried. You can then add the GitHub Closes #...
annotations to the description to link the PR to the issues that it closes.
Lastly, for the extension plugin you made, it doesn't seem like you actually need any of the filters you're introducing here. You can just use the render_block_core/code
filter to inject your desired markup along with the HTML API introduced in WordPress 6.2.
Thanks, will do. I appreciate you checking it out for me.
…On Mon, Oct 9, 2023 at 14:53 Weston Ruter ***@***.***> wrote:
***@***.**** commented on this pull request.
Thanks for the PR! Could you surface the commit messages in which you
explain the reasons for the new hooks to be PR description? This will make
sure they aren't buried. You can then add the GitHub Closes #...
annotations to the description to link the PR to the issues that it closes.
Lastly, for the extension plugin you made, it doesn't seem like you
actually need any of the filters you're introducing here. You can just use
the render_block_core/code filter to inject your desired markup along
with the HTML API
<https://make.wordpress.org/core/2023/03/07/introducing-the-html-api-in-wordpress-6-2/>
introduced in WordPress 6.2.
—
Reply to this email directly, view it on GitHub
<#766 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAE3M2MDOMYE7XTMDZ6YGYTX6RI2ZAVCNFSM6AAAAAA5XEDLQKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTMNRVGE3TEMRQGU>
.
You are receiving this because you authored the thread.Message ID:
<westonruter/syntax-highlighting-code-block/pull/766/review/1665172205@
github.com>
|
This PR seeks to add several actions and filters that'll help others extend the block.
Resolves #488 #191
Background
I'd like to add a few addons for this plugin:
I need several filters/actions to do this, hence this PR. I've put together a proof-of-concept of the first addon, which adds a copy button to the code block.
I've done my best to only insert actions/filters where needed. To see examples of some of these in use, please check out my addon code for this plugin: https://github.com/DLXPlugins/syntax-highlighting-code-block-copy-addon/blob/main/syntax-highlighting-code-block-copy-addon.php
Proof of Concept
Please see repo release with attached ZIP files: https://github.com/DLXPlugins/syntax-highlighting-code-block-copy-addon/releases/tag/1.0.0
Thank you for considering this PR.