Skip to content
Polmonite edited this page Sep 21, 2019 · 1 revision

String

These are used to manipulate strings. Available string filters are:

  • lowercase: transform the string in lowercase;
  • uppercase: transform the string in uppercase;
  • capitalize: capitalize the string;
  • customcase:{delimiter}: transform the string in customcase, which is like a snake_case with a custom $delimiter, passed as an argument;
  • kebabcase: transform the string in kebab-case;
  • snakecase: transform the string in snake_case;
  • pascalcase: transform the string in PascalCase;
  • camelcase: transform the string in camelCase;
  • slug: transform the string in a slug through WordPress sanitize_title function;
  • append:{suffix}: append the specified $suffix to the string;
  • prepend:{prefix}: prepend the specified $prefix to the string;
  • padleft:{pad_length},{pad_string}: pad a string to the left with $pad_string until it reaches a length of $pad_length;
  • padright:{pad_length},{pad_string}: pad a string to the right with $pad_string until it reaches a length of $pad_length;
  • padboth:{pad_length},{pad_string}: pad a string both to the left and the right with $pad_string until it reaches a length of $pad_length;
  • hash: creates an hash of the string;
  • escape_html: calls the htmlspecialchars function;
  • replace:{what},{?with},{?force_string_replacement}: executes a string replacement of $what with $with on the string; the second argument, if omitted, defaults to empty string; this methods will try and guess if the passed $what parameter is a regular expression (regexp must be passed using the / delimiters), but this behaviour can be ignored by passing the third argument $force_string_replacement equal to 1 (it defaults to 0);
  • truncate:{max_length},{?pad_with}: truncates the string, if needed, to a maximum of $max_length characters; a second optional parameter, $pad_with, can be passed; this will become the end of the string only in case it needs to be truncated (useful to add ellipsis or similar text).

Other

Extend Malini

  • Create your own Accessor
  • Create your own Decorator
  • Available Extensions
    • Malini\Aeria
    • Malini\YOAST
    • Malini\ACF
Clone this wiki locally