Skip to content

Instantly share code, notes, and snippets.

View gmazzap's full-sized avatar

Giuseppe Mazzapica gmazzap

View GitHub Profile
@gmazzap
gmazzap / Controller.php
Last active March 15, 2024 23:18
WordPress plugin to ease the creation of virtual pages.
<?php
namespace GM\VirtualPages;
/**
* @author Giuseppe Mazzapica <giuseppe.mazzapica@gmail.com>
* @license http://opensource.org/licenses/MIT MIT
*/
class Controller implements ControllerInterface {
private $pages;
@gmazzap
gmazzap / www-post-thumb.php
Last active January 28, 2023 03:57
WordPress plugin that allow to use an external image url as featured image.
<?php namespace GM\WWWPostThumbnail;
/**
* Plugin Name: WWW Post Thumbnail
* Description: Allow to use an external image url as featured image.
* Plugin URI: https://gist.github.com/Giuseppe-Mazzapica/928bc22e5f49a654cf7c
* Author: Giuseppe Mazzapica
* Author URI: https://github.com/Giuseppe-Mazzapica
* License: MIT
* Version: 0.1.0
*
@gmazzap
gmazzap / revoke-profile-access.php
Last active February 6, 2020 18:50
Simple WordPress plugin that allow administrators to revoke access to profile to some users. Wrote to anwer a question on WPSE: http://wordpress.stackexchange.com/q/141743/35541
<?php
/**
* Plugin Name: Revoke Profile Access
* Description: Allow administrators to revoke access to profile to some users
* Plugin URI: http://wordpress.stackexchange.com/q/141743/
* Author: G. M.
* Author URI: http://wordpress.stackexchange.com/users/35541/g-m
* License: GPLv2
*
*/
<?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) {
@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 / 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>
*/
@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",
<?php
// require the class
@require_once __DIR__ . '/mycaptcha.php';
// defaults
$w = 110;
$h = 35;
$random_dots = 0;
$random_lines = 20;
$captcha_text_color = "0x#B9B098";

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 / PointersManager.php
Last active January 13, 2017 19:06
Pointers Tour (WPSE 162794)
<?php namespace GM;
class PointersManager implements PointersManagerInterface {
private $pfile;
private $version;
private $prefix;
private $pointers = array();
public function __construct( $file, $version, $prefix ) {