Skip to content

Refactor #6

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 2 commits into from
Apr 8, 2025
Merged

Refactor #6

merged 2 commits into from
Apr 8, 2025

Conversation

soderlind
Copy link
Owner

This pull request includes several updates to the additional-javascript plugin to improve functionality and maintainability. The most important changes include updating the plugin version, defining a version constant for cache-busting, modifying JavaScript and CSS enqueuing logic, updating capabilities for custom JavaScript settings, and refining exception handling.

Version Update and Cache-Busting:

  • Updated the plugin version to 1.1.0 and defined a constant ADDITIONAL_JAVASCRIPT_VERSION for cache-busting assets. [1] [2]

JavaScript and CSS Enqueuing:

  • Modified the handle and dependencies for enqueuing JavaScript and CSS, and added file existence checks before enqueuing.

Capability Update:

  • Changed the capability required to edit custom JavaScript from edit_css to unfiltered_html.

Exception Handling:

  • Updated exception handling in the Soderlind_Customize_Custom_JavaScript_Setting class to use fully qualified class names and improved error messages.

JavaScript Code Refinement:

  • Refined the JavaScript code for the customizer preview to remove jQuery dependency and use vanilla JavaScript. [1] [2]

- Updated function signatures and array formatting in `additional-javascript.php` for improved readability.
- Changed `default_js_template` function declaration style for consistency.
- Modified array syntax to use consistent spacing in `register_post_type_javascript` and `register_additional_javascript` functions.
- Refactored jQuery usage to vanilla JavaScript in `additional-javascript-preview.js` for better performance and compatibility.
- Enhanced comments to accurately describe functionality, particularly in the `custom_javascript` preview handler.
…aScript settings

- Updated plugin version from 1.0.1 to 1.1.0 in additional-javascript.php.
- Added a new comment for the version definition to clarify its purpose for cache-busting assets.
- Changed capability from 'edit_css' to 'unfiltered_html' in class-custom-javascript-control.php to allow broader editing permissions.
- Enhanced constructor documentation to specify exceptions and parameter types more clearly.
- Improved code formatting for better readability and consistency.
@soderlind soderlind merged commit 6aec7ab into master Apr 8, 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.

1 participant