Tag: Code

  • Don’t use strlen()

    Don’t use strlen()

    Each time I see someone use strlen() I cringe. It will break. Despite its name, strlen() doesn’t count characters. It counts bytes. In UTF-8 a character may be up to four bytes long. So what happens if we use strlen() and its companion substr() to shorten the title of post? <?php # -*- coding: utf-8…

  • Best Practice for Multilanguage WordPress Content? New Plugin!

    Best Practice for Multilanguage WordPress Content? New Plugin!

    Since the beginning of WordPress the desire to publish the content in different languages is huge. But the topic can quickly become complex, because not only the rendering of content in the form of text in different languages ​​is an issue, we also have to take care of the meta data for content, for images…

  • Separate Logic From Output

    Separate Logic From Output

    Once HTML is defined within a function for output, the HTML will be separated from the logic! In this case the function is defined twice. A function contains only logic and values ​​are returned only as return. The second function will contain HTML, test logic, loops or hooks and outputs values ​​as echo. Ok, the…

  • Adding Custom Fields to WordPress User Profile

    Adding Custom Fields to WordPress User Profile

    The user profile of WordPress can be fairly easily adapted to add your own values​​. So you can add the necessary fields according to your requirements. Here is how you do it, we add a field for the address and the content will be stored in the database. Various hooks in WordPress make sure that…

  • Restrict Mime Types on WordPress Media Upload

    Restrict Mime Types on WordPress Media Upload

    WordPress has changed the library in version 3.3 – which I think is an improvement. The restrictions in terms of file types remains and you can control them via hook. So you can limit or extend the file-types. Via two hooks, this is done quickly and there is a notification displayed in your backend which…

  • Add Icon to Site Link in the WordPress Admin Bar

    Add Icon to Site Link in the WordPress Admin Bar

    Each button in the Admin bar has a self-defining and space-saving icon. But the link to the blog frontend (which is represented as a blog title), has no icon. If you want, you can change it quickly – here is a small solution.