Skip to content

Instantly share code, notes, and snippets.

View schlessera's full-sized avatar

Alain Schlesser schlessera

View GitHub Profile
@schlessera
schlessera / shortcode-copyright.php
Created April 4, 2015 20:03
Shortcode to display copyright notice with current year

Keybase proof

I hereby claim:

  • I am schlessera on github.
  • I am schlessera (https://keybase.io/schlessera) on keybase.
  • I have a public key ASAwZ3hewGFJXOlKo5p5dYD5Q-gmmvQDfsbyTKID3Uo09wo

To claim this, I am signing this object:

@schlessera
schlessera / Plugin.php
Last active September 29, 2017 17:15
Using Value Objects for Dependency Injection
<?php
class Plugin
{
protected $plugin_root;
private $loaded;
public function __construct(PluginRoot $plugin_root)
{
@schlessera
schlessera / translatable_string.php
Last active January 18, 2017 11:56
Translatable string with multiple links that can be reordered and renamed
<?php
/**
* Translatable string with multiple links that can be reordered and renamed
* @author Alain Schlesser (alain.schlesser@gmail.com)
*
* @see http://php.net/manual/function.preg-replace.php
* @see http://codex.wordpress.org/Function_Reference/_2
*/
@schlessera
schlessera / .htaccess
Created May 8, 2015 19:12
Redirect HTTP to HTTPS, for the main domain as well as all subdomains.
# Redirect HTTP to HTTPS, for the main domain as well as all subdomains.
#
# Example:
# http://domain.com/ => https://domain.com/
# http://subdomain.domain.com/ => https://subdomain.domain.com/
#
# Make sure you replace "replacewithyourdomain" with your actual root domain!
#
# @author: Alain Schlesser <alain.schlesser@gmail.com>
@schlessera
schlessera / README.md
Created March 10, 2016 10:41
Accessing WP plugin code from a theme
@schlessera
schlessera / example-plugin.php
Created March 10, 2016 10:40
Accessing WP plugin code from a theme
<?php
/**
* Example plugin.
*
* @see http://wordpress.stackexchange.com/questions/220286/what-is-the-best-way-to-instantiate-a-class-of-a-plugin-in-your-wordpress-theme/
*
* @wordpress-plugin
* Plugin Name: Example plugin.
* Description: Accessing a plugin object from a theme.
* Version: 0.1.0
@schlessera
schlessera / phpfeature-example.php
Created January 14, 2016 09:22
PHPFeature Example Usage Code.
<?php
/*
* PHPFeature example usage code
*/
// Array of strings to define what features you need.
$features = array( 'namespaces', 'traits' );
// Instantiate the PHPFeature library.
// When you don't provide a version number as the first argument,
@schlessera
schlessera / OrderedInvoke.php
Last active September 7, 2015 08:03
Simple WordPress Settings API class example.
<?php
/**
* OrderedInvokeTrait
*
* @package BrightNucleus_Core
* @author Alain Schlesser <alain.schlesser@gmail.com>
* @license GPL-2.0+
* @link http://www.brightnucleus.com/
* @copyright 2015 Alain Schlesser, Bright Nucleus
*/
@schlessera
schlessera / responsive-iframe.css
Last active August 29, 2015 14:21
Make an IFrame (like video, flash, ...) responsive.
/* Responsive IFrame example
* @author Alain Schlesser <alain.schlesser@gmail.com>
/* The wrapper gets resized using padding-bottom with a percentage value. This
* way, it's height is always directly dependent on its width */
.iframe-wrapper {
/* Necessary so we can position the contained IFrame absolutely */
position: relative;