I AM LISTENING TO
|
WHAT I LIKE
  • English
  • German


BLOG FILTER



htmLawed is a PHP lib that:

  • makes HTML markup in text secure and standard-compliant
  • processes text for use in HTML, XHTML or XML documents
  • restricts HTML elements, attributes or URL protocols using black- or white-lists
  • balances tags, check element nesting, transform deprecated attributes and tags, make relative URLs absolute, etc.

Take a look here

readmore

While building plugins for WordPress is fun, it often means repeating tasks over and over again. I love clean and organized code! For my last internal project, a Visual Composer addon bundle,  I decided to build a modular system.

So I have one central plugin, handling multiple modules that access methods from the plugin. This allows me to reuse public and admin routines. In combination with _autoload and traits, this makes the codebase lean and mean.

I also decided to use TWIG fully for the presentation layer. Each module can be activated, deactivated, registers their own public and admin views, admin menus, ajax calls, dashboard widgets and additional context.

I am currently in the process of cleaning this up and will share some more details soon.

Cheers
Alex

  1. __autoload & traits
  2. TWIG
  3. Timber

readmore

“WebP is an image format employing both lossy and lossless compression. It is currently developed by Google, based on technology acquired with the purchase of On2 Technologies.” – Wikipedia

As the WebP is not widely supported, you need to use polyfills or workarounds to actually use it. But it makes a lot of sense when you are building image heavy applications for the web. It decreases file-sizes immensely and supports transparency as PNG does.

To allow WebP upload in WordPress, add this to your functions.php:

Browsers with native support will show WebP images natively, for browsers without support deploy WebPJS developed by Google. Download and add it to your theme functions.php

This should do the trick and enable WebP for all modern browsers, see browser support on the WebPJS development page.

Here another little nice trick to check for WebP using Javascript and replace webp with png images.

Enjoy
Alex

readmore
22. March 2015

scrollReveal

Easily reveal elements as they enter the viewport. No dependancies.

Usage examples:

Github: scrollReveal 

readmore

Pure CSS

Using Modernizer + jQuery

Modernizer

 Custom detection of SVG

 

 

readmore

Just add that to your themes functions.php.

readmore

Very impressive javascript physics engine.

Github
Spiderweb Example

readmore

The SVG converter is a web frontend to a jQuery Plugin, that allows you to include those line drawings on your webpage.

Lazy Line Painter

readmore

Single inheritance has often been the limitation for PHP. This means that a class can only inherit from one other class. Often classes share the same methods and it would be beneficial to allow reuse and prevent duplication.

In PHP 5.4 a new feature was added, known as Traits. A Trait is like a Mixin, allowing to use / mix classes into existing classes. This means code reduction and less duplication.

Example of a Trait

This trait can than be used in other classes:

Both classes can now use the Shareable trait.

The benefit is less code duplication. The drawback is, that not all used methods are visible within the source-code of the class. So before moving a method to a trait, make sure that you will actually reuse it ;)

I have been restructuring huge amounts of code over the past months and traits are helping to keep things far more organized.

In combination with __autoload its a real nice way to cleanup your code toolbox.

Happy coding
Alex

  1. Traits
  2. Autoload

readmore

When projects are getting bigger, its always nice to split things up and prepare parts of your code for general reuse.

PHP Traits (PHP 5.4+) are a nice way to do this. Adding multiple Traits or classes, requires you to make sure all are being included.

Here is a nice way to register both with the __autoload function

Traits are loaded when you specify their use in a class.

 

 

readmore