Skip to content

Instantly share code, notes, and snippets.

View gmazzap's full-sized avatar

Giuseppe Mazzapica gmazzap

View GitHub Profile
@gmazzap
gmazzap / gm-fsdfm.php
Last active November 20, 2015 07:03
WordPress plugins that allows to use the distraction-free mode that was active pre 4.1 WP version.
<?php namespace GM\FSDFM;
/**
* Plugin Name: Fullscreen Distraction-Free Mode (pre v4.1)
* Description: Allows to use the distraction-free mode that was active pre 4.1 WP version.
* Plugin URI: https://gist.github.com/Giuseppe-Mazzapica/c081ce03a68b00d983d5
* Author: Giuseppe Mazzapica
* Author URI: https://gm.zoomlab.it
* License: MIT
* Version: 1.0.0
*/
@gmazzap
gmazzap / gm_optimum.php
Last active August 29, 2015 14:11
Optimum: a class to filter arrays with callbacks.
<?php namespace GM;
use SplObjectStorage;
class Optimum
{
private $data;
private $raw;
private $map;
private $storage;
@gmazzap
gmazzap / loop.php
Last active August 29, 2015 14:07 — forked from tomjn/loop.php
<?php
array_walk($GLOBALS['wp_query']->posts, function($post, $i, $wp_query) {
$GLOBALS['post'] = $post;
$wp_query->the_post();
// loop code
the_title();
the_content();
@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 ) {
@gmazzap
gmazzap / Controller.php
Last active April 22, 2024 12:08
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 / queried_posts_terms
Created August 25, 2014 05:52
A WordPress template tag that retrieve terms from specific taxonomies attached to the all the currently queried posts (in main query).
function queried_posts_terms( $taxonomies = 'category' ) {
global $wp_query, $wpdb;
if ( empty( $wp_query->posts ) ) return FALSE;
$ids = wp_list_pluck( $wp_query->posts, 'ID' );
$taxonomies = array_filter( (array) $taxonomies, function( $tax ) {
if ( is_string( $tax ) ) {
$tax = sanitize_title( $tax );
return taxonomy_exists( $tax ) ? esc_sql( $tax ) : NULL;
}
} );
@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 / index.html
Last active August 29, 2015 14:02
Muschiatini
<!doctype html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Muschiatini Dixit</title>
<meta name="description" content="Muschiatini Dixit">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
</head>
@gmazzap
gmazzap / get_term_related_terms.php
Last active August 29, 2015 14:00
WordPress (monster) function that retrieve terms from one or more taxonomies having posts "in common" with given term(s) form a different taxonomy.
@gmazzap
gmazzap / gm-random-background.php
Last active January 1, 2016 20:45
Simple WordPress plugin that extends WP custom background feature to show a random image that change hourly. Images are selected via a checkbox on attachment edit screen. Wordpre for a WPSE anser, see http://wordpress.stackexchange.com/questions/141778/35541
<?php
/**
* Plugin Name: GM Random Background
* Description: Extends WP custom background feature to show a random image that change hourly
* Plugin URI: http://wordpress.stackexchange.com/questions/141778/35541
* Author: G. M.
* Author URI: http://wordpress.stackexchange.com/users/35541/g-m
*
*/