Skip to content
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

Docs: Add note about enqueueing assets in the iframe and trim whitespace. #54125

Merged
merged 4 commits into from Sep 6, 2023

Conversation

ndiego
Copy link
Member

@ndiego ndiego commented Sep 1, 2023

What?

Updates the Enqueueing assets in the Editor doc based on @ellatrix's feedback. While updating the doc, I also trimmed all extra whitespace.

Edit: in preparing this PR, a number of typos were also found and fixed.

@ndiego ndiego added the [Type] Developer Documentation Documentation for developers label Sep 1, 2023
@ndiego ndiego requested a review from ellatrix September 1, 2023 21:18
@ndiego ndiego self-assigned this Sep 1, 2023
@alexstine
Copy link
Contributor

Conflicts. 😞 Happy to review once resolved.

Copy link
Contributor

@alexstine alexstine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ndiego In the wp_enqueue_script and wp_enqueue_style function calls, they are terminated via ); but there is an existing } on the following line. I believe this will cause a syntax error when executing this function. The closing } for the function should be at the same indent level hints the last } before the add_action hook. The others should likely be removed.

docs/how-to-guides/enqueueing-assets-in-the-editor.md Outdated Show resolved Hide resolved
docs/how-to-guides/enqueueing-assets-in-the-editor.md Outdated Show resolved Hide resolved
Copy link
Contributor

@alexstine alexstine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ndiego There is still a problem with this first code snippet.

/**
 * Enqueue Editor assets.
 */
function example_enqueue_editor_assets() {
    wp_enqueue_script(
        'example-editor-scripts',
        plugins_url( 'editor-scripts.js', __FILE__ ) );
    }
    wp_enqueue_style(
        'example-editor-styles',
        plugins_url( 'editor-styles.css', __FILE__ ) );
    }
}
add_action( 'enqueue_block_editor_assets, 'example_enqueue_editor_assets' );

Rewrite to:

/**
 * Enqueue Editor assets.
 */
function example_enqueue_editor_assets() {
    wp_enqueue_script(
        'example-editor-scripts',
        plugins_url( 'editor-scripts.js', __FILE__ )
    );
    wp_enqueue_style(
        'example-editor-styles',
        plugins_url( 'editor-styles.css', __FILE__ )
    );
}
add_action( 'enqueue_block_editor_assets, 'example_enqueue_editor_assets' );

@ndiego
Copy link
Member Author

ndiego commented Sep 3, 2023

Thanks @alexstine, and there was a missing ' in the add_action. All fixed. I also updated the description of this PR to reflect these changes 😅

Copy link
Contributor

@alexstine alexstine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ndiego ndiego merged commit e1821ba into trunk Sep 6, 2023
49 checks passed
@ndiego ndiego deleted the update/euqueueing-assets-doc branch September 6, 2023 17:59
@github-actions github-actions bot added this to the Gutenberg 16.7 milestone Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants