Skip to content

Instantly share code, notes, and snippets.

View schlessera's full-sized avatar

Alain Schlesser schlessera

View GitHub Profile
@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 / 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 / README.md
Created March 10, 2016 10:41
Accessing WP plugin code from a theme
@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 / 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 / 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)
{

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 / shortcode-copyright.php
Created April 4, 2015 20:03
Shortcode to display copyright notice with current year
@schlessera
schlessera / RoboFile.php
Created December 14, 2019 14:46
Simple script to quickly create a fresh WordPress installation in a subfolder.
<?php declare( strict_types=1 );
final class RoboFile extends \Robo\Tasks {
public function createEmpty( string $name, string $tld = 'localhost', string $email = 'alain.schlesser@gmail.com' ) {
$io = $this->io();
$root = __DIR__;
$io->title( 'Creating an empty local WordPress site' );
@schlessera
schlessera / README.md
Last active February 3, 2020 23:21
Simple script to quickly create a fresh WordPress installation in a subfolder.