Skip to content

Instantly share code, notes, and snippets.

View gmazzap's full-sized avatar

Giuseppe Mazzapica gmazzap

View GitHub Profile
@gmazzap
gmazzap / VersionNumber.php
Created March 24, 2019 19:37
Version number parser and comparator compatible with both Semver and WordPress version numbers.
<?php
/**
* Copyright 2019 Inpsyde GmbH
*
* @license MIT https://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@gmazzap
gmazzap / composer.json
Created April 7, 2018 07:56
Simple example for WCTRN workshop.
{
"name": "gmazzap/wps-wctrn",
"description": "Simple example for WCTRN workshop.",
"type": "project",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"wecodemore/wpstarter": "^2.4"
},
"license": "MIT",
@gmazzap
gmazzap / Brain_HtmlTokenizer.php
Created February 18, 2018 20:08
A basic, PHP 5.2+ compatible, HTML parser.
<?php
/**
* Brain_HtmlTokenizer class file.
*
* (c) Giuseppe Mazzapica
*
* @license http://opensource.org/licenses/MIT MIT
* @author Giuseppe Mazzapica <giuseppe.mazzapica@gmail.com>
*/
<?php
namespace gmazzap;
/**
* @param callable $looper Callback that receives post object, post index and current WP_Query.
* It is possible to use any template tags inside the callback.
* @param array $args Array of WP_Query arguments. Optional, when not provided, main query will be used.
*/
function loop(callable $looper, array $args = null) {

Keybase proof

I hereby claim:

  • I am gmazzap on github.
  • I am gmazzap (https://keybase.io/gmazzap) on keybase.
  • I have a public key ASAxrrn1I4TqGBN72iGlL41U1bCTwXWnfaK50UT4nQAGYAo

To claim this, I am signing this object:

@gmazzap
gmazzap / AutoPaginatedQuery.php
Last active April 8, 2016 21:49
`WP_Query` subclass that takes a non-paginated query and split into different paginated queries offering a transparent interface to "standard loop" usage.
<?php
namespace GM;
/**
* `WP_Query` subclass that takes a non-paginated query and split into different
* paginated queries offering a transparent interface to "standard loop" usage.
*
* The class is not 100% transparent:
* - the var `$posts` and the method `get_posts()`, that are not used directly
* in standard loop usage, here don't return array of all posts, but only posts
@gmazzap
gmazzap / LICENSE
Last active August 24, 2016 20:53
Format url for Google sitemaps
The MIT License (MIT)
Copyright (c) 2016 Giuseppe Mazzapica
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WIT
@gmazzap
gmazzap / Angie.php
Last active April 6, 2016 17:35
Very simple, quite powerful, extensible, plain-PHP one-class template engine.
<?php namespace GM;
/**
* Angie. Very simple, and quite powerful, plain PHP template engine.
*
* @author Giuseppe Mazzapica <giuseppe.mazzapica@gmail.com>
* @license http://opensource.org/licenses/MIT MIT
*/
class Angie
{
<?php
/**
* @author Giuseppe Mazzapica <giuseppe.mazzapica@gmail.com>
* @license http://opensource.org/licenses/MIT MIT
*/
class MetaboxStealer
{
/**
* @var bool
@gmazzap
gmazzap / Arraize.php
Created January 20, 2015 01:25
Recursively convert an array or a traversable object into a nested array. Optionally convert all "atomic" items to strings and optionally HTML-encode all strings.
<?php namespace GM;
use Traversable;
use JsonSerializable;
/**
* Stateless class that recursively convert an array or a traversable object into a nested array.
* Optionally convert all "atomic" items to strings and optionally HTML-encode all strings.
* Array and traversable objects are all recursively converted.
* Non-traversable objects are converted to array, in 1st available among following methods: