Skip to content

w-biggs/wp-left-pad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

wp-left-pad

Because programming sucks.

Installation

Download master.zip, then install it via the "Add Plugin" button on WordPress's "Plugins" page.

Usage example

Just use the shortcode in any WordPress text area. Easy peasy. A few examples:

[left-pad foo 5]
// => "  foo"

[left-pad foobar 6]
// => "foobar"

[left-pad 1 2 0]
// => "01"

[left-pad 17 5 0]
// => "00017"

Note: The third argument should be a single character. Obviously.

Release History

  • 1.0
    • First proper release
    • CHANGE: Fix handling of multi-byte pad characters
  • 0.1
    • Work in progress

Meta

Distributed under the WTFPL. Because who cares. See LICENSE for more information.

FAQ

Why?

I originally had the idea to do this after someone on Reddit joked about WordPress plugins being like node modules. I responded with a low-effort left-pad joke, but soon thought "hey, that might actually be funny to do!". It was a fun little exercise to spend a little time on.

Boooring. You just have to use str_pad(), right?

Wrong. str_pad() doesn't handle multi-byte characters correctly, and while I tried to replicate the functionality of left-pad as closely as possible, multi-byte characters needed to work correctly. Otherwise, I couldn't use non-breaking spaces (which are encoded as c2 a0 in UTF-8); I needed to use non-breaking spaces as WordPress automatically consolidates consecutive normal spaces into one space.

Releases

No releases published

Packages

No packages published

Languages