ProcessWire 3.0.105

This latest version on the dev branch adds a new site profile to the core, adds useful new functions to our $mail API variable, and makes significant enhancements to our $sanitizer API variable.

New site profile in core

The “Regular” site profile has been added to the core as an installation option. You might already be familiar with this site profile from the last year, and it's been available on its own GitHub repo for quite some time. This site profile demonstrates a lot of PW3 specific features in ways the other profiles don't, and I thought it was a good time to go ahead and add it.

This site profile is still fairly simple, not unlike the default site profiles, but it goes quite a bit further in serving as a good introduction to developing with ProcessWire. For example, it demonstrates these things that the other core profiles don't:

  • Use of Markup Regions
  • Integration of a front-end framework (Uikit 3 in this case)
  • Implementation of a basic blog with categories and comments
  • Use of front-end editing
  • Use of Page references
  • Using a library of helper functions for front-end output
  • Use of the $cache API variable for caching markup (new)
  • Use of pagination

If you are already familiar with the Regular site profile, this version added to the core is upgraded a bit from the one previously available on GitHub. It includes a much more powerful ukNav() function for rendering navigation. This is used to render the off-canvas navigation, which now lets you navigate not just primary navigation, but secondary navigation too (and further, if you want it). This version of the profile on the core also adds a demonstration of the $cache API variable, for caching that off-canvas navigation. While not really necessary here, it does demonstrate just how simple and easy it is to use ProcessWire's built in markup caching capabilities. Lastly, this version of the profile lets you choose between CDN and locally hosted versions of Uikit 3 and jQuery.

All in all, I think this site profile serves as a useful introduction to modern development in ProcessWire, as well as a good starting point for developing a ProcessWire site using Uikit 3, or another framework, if preferred. If you find any ways that you think we can improve it or simplify it, please be sure to let us know.

Updates to the $mail API variable

Added a new $mail->mail() function which does the same thing as $mail->send(), except that it acts as a drop-in replacement for PHP’s mail() function, maintaining the same arguments. Meaning, you can generally change a PHP mail() call to a WireMail call just by prepending $mail-> to it, i.e. $mail->mail(...).

Added a new $mail->sendHTML() function which works the same as the $mail->send() function except that it assumes the given $body is HTML rather than text. The text-only version is automatically generated from the HTML version. An equivalent $mail->mailHTML() function has also been added, which is the same thing except that it duplicates the arguments from PHP’s mail() function.

Several parts of the WireMail class have been rewritten to improve various internal aspects of it. However, the external interface has not changed, nor should it affect any WireMail modules that extend it.

Upgrades to $sanitizer

Improvements to text() and textarea() sanitizers
Several new options have been added, as outlined below:

  • stripSpace (bool or string)
    Strip whitespace? Specify true or character to replace whitespace with (default=false).

  • reduceSpace (bool or string)
    Reduce consecutive whitespace to single? Specify true or character to reduce to (default=false). This is an alternative to the stripSpace option, the two should not be used together.

  • convertEntities (bool)
    Convert HTML entities to equivalent character(s)? (default=false).

  • truncateTail (bool)
    If truncate necessary to achieve requested maxLength, truncate from the end/tail of the string rather than the head? Use false to truncate from the head (default=true).

  • stripIndents (bool)
    Remove indents (space/tabs) at the beginning of lines? (default=false). This option applies only to the textarea() sanitizer, since the text() sanitizer doesn't allow more than one line.

Improvements to $sanitizer->unentities()
The unentities() function has been improved to support a new $flags option that supports converting all entities, including those that PHP’s functions do not recognize. It converts all named entities, all decimal based entities and all hex based entities. If any apparent entities remain, it removes them. To use this option, specify boolean true for the $flags argument. i.e. $sanitizer->unentities($str, true);

New $sanitizer->removeWhitespace() function
This newly added function can remove, collapse or replace all known kinds of possible whitespace in a string. This goes well beyond just spaces, tabs and newlines. It includes 99 different types of UTF-8 and HTML entity based representations of whitespace, ensuring nobody can play any whitespace games or trickery with your strings. You can optionally collapse them to a single whitespace or replace the with a whitespace character that you specify. In addition, you can optionally choose to allow certain kinds of whitespace by specifying it as an option.

In addition to the above, there are also various other small fixes and updates in the core, as usual. A huge thanks to those that help us out every week on GitHub. I hope that you all have a great weekend and enjoy reading the ProcessWire Weekly.


  • Zahari M.

    Zahari M. 3 weeks ago 00

    Awesome news Ryan!! Been waiting patiently for a new site profile to appear from you for quiet a while now! Thanks so much! Can't wait to try it out!

  • Mont

    Mont 2 weeks ago 00

    "Lastly, this version of the profile lets you choose between CDN and locally hosted versions of Uikit 3 and jQuery."

    Thank you Ryan.

  • MrSnoozles

    MrSnoozles 2 weeks ago 10

    Again, a bunch of useful additions to an already excellent system. Love how it keeps getting better with every update.

Post a Comment

Your e-mail is kept confidential and not included with your comment. Website is optional.