Skip to content

Refactor hook example generation logic#5

Closed
obenland wants to merge 4 commits intoakirk:mainfrom
obenland:update/default-examples
Closed

Refactor hook example generation logic#5
obenland wants to merge 4 commits intoakirk:mainfrom
obenland:update/default-examples

Conversation

@obenland
Copy link
Copy Markdown
Contributor

This is probably more a matter of taste, so please feel free to close this if it doesn't match your preference.

Changes in this PR would generate non-closure example callbacks.

Before

add_filter(
    'activitypub_extract_mentions',
    function (
        array $mentions,
        string $content,
        WP_Post $post
    ) {
        // Your code here
        return $mentions;
    },
    10,
    3
);

After

function prefixed_filter_callback( array $mentions, string $content, WP_Post $post ) {
    // Your code here.
    return $mentions;
}
add_filter( 'activitypub_extract_mentions', 'prefixed_filter_callback', 10, 3 );

obenland added 4 commits July 23, 2025 11:01
Improves the generation of auto-generated hook examples by separating hook type and function, refining function signature formatting, and updating parameter handling for better readability and PHP compatibility. Also updates the registration line to use the correct callback and parameters.
Replaces manual string concatenation for function parameters with a dedicated $param_string variable, simplifying and clarifying the construction of function signatures for extracted hooks.
Updated the hook registration line to use double quotes and curly braces for variable interpolation, ensuring correct formatting of hook and callback names.
@akirk
Copy link
Copy Markdown
Owner

akirk commented Jul 24, 2025

I guess a good path forward is to make this configurable.

@akirk
Copy link
Copy Markdown
Owner

akirk commented Jul 26, 2025

Implemented in #8.

@akirk akirk closed this Jul 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants