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

Optimize _wp_normalize_relative_css_links() #4297

Conversation

westonruter
Copy link
Member

@westonruter westonruter commented Apr 3, 2023

  • Replace preg_match_all() and its secondary str_replace() call with preg_replace_callback().
  • Fix case where paths beginning with http and https (but not http: and https:) were erroneously not counted as relative.
  • Improve code style and readability by consolidating conditions and returning once.
  • Use str_starts_with() consistently instead of strpos().

Trac ticket: https://core.trac.wordpress.org/ticket/58069


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Copy link
Member

@adamsilverstein adamsilverstein left a comment

Choose a reason for hiding this comment

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

Nice!

…e-relative-css-links

* origin/trunk: (33 commits)
  Users: Cache database queries within `WP_User_Query` class.
  Coding Standards: Use strict comparison in `wp-admin/includes/class-wp-ms-sites-list-table.php`.
  Twenty Nineteen: Fix a translation issue in Comments navigation text.
  Coding Standards: Use strict comparison where `trim()` is involved.
  Coding Standards: Use strict comparison where `substr()` is involved.
  Coding Standards: Use strict comparison where `strlen()` is involved.
  Coding Standards: Rename the `$myHTML` parameter to `$text` in `htmlentities2()`.
  Coding Standards: Use strict comparison in `wp-includes/http.php`.
  Media: Render attachment custom fields for new uploads.
  Coding Standards: Rename the `$qtInit` and `$mceInit` variables in `_WP_Editors`.
  Media: Deprecate `wp-admin/media.php`.
  Docs: Revise comments using “we” in various docblocks.
  Coding Standards: Use strict comparison in `wp-admin/maint/repair.php`.
  Docs: Fix a typo in `wp-includes/rss.php` inline comments.
  Twenty Twenty-Three: Add `style-variations` tag in `style.css`.
  Coding Standards: Use strict comparison where `count()` is involved.
  Coding Standards: Replace `include_once` with `require_once` for required files.
  Networks and Sites: Fix incorrect color for Theme enabling admin notices.
  Twenty Twenty-One: Replace `include_once` with `require_once` for required classes.
  Comments: Add missing arguments for `get_comment_time()` in `comment_time()`.
  ...
@westonruter
Copy link
Member Author

Committed to trunk: https://core.trac.wordpress.org/changeset/55658

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.

3 participants