Skip to content

Instantly share code, notes, and snippets.

Alain Schlesser schlessera

Block or report user

Report or block schlessera

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@schlessera
schlessera / phpfeature-example.php
Created Jan 14, 2016
PHPFeature Example Usage Code.
View phpfeature-example.php
<?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 Mar 10, 2016
Accessing WP plugin code from a theme
View example-plugin.php
<?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 Mar 10, 2016
Accessing WP plugin code from a theme
View README.md
@schlessera
schlessera / Controller.php
Last active May 29, 2016
Example of bootstrapping a WordPress plugin.
View Controller.php
<?php
// file: src/Controller.php
/**
* Example Plugin Controller.
*/
namespace Example\Plugin;
use BrightNucleus\Config\ConfigInterface;
@schlessera
schlessera / .htaccess
Created May 8, 2015
Redirect HTTP to HTTPS, for the main domain as well as all subdomains.
View .htaccess
# 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 Jan 18, 2017
Translatable string with multiple links that can be reordered and renamed
View translatable_string.php
<?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 / Autoloader.php
Last active Apr 11, 2017
Generic Autoloader
View Autoloader.php
<?php namespace Generic;
use RuntimeException;
/**
* Class Autoloader.
*
* This is a custom autoloader to replace the functionality that we would
* normally get through the autoloader generated by Composer.
*
@schlessera
schlessera / Plugin.php
Last active Sep 29, 2017
Using Value Objects for Dependency Injection
View Plugin.php
<?php
class Plugin
{
protected $plugin_root;
private $loaded;
public function __construct(PluginRoot $plugin_root)
{
@schlessera
schlessera / README.md
Created Jul 29, 2016
Real-time Log Viewer Example
View README.md

Partial real-time log viewer example

This is a (partial) example to demonstrate the interaction between different reusable components to build an admin page in the WordPress back-end that shows a near-real-time display of the last 30 lines of my log files.

This code will not work as is, as some of it depends on a larger architecture system. Some of the files have been shortened, and the usual file headers and copyright notices have been removed for brevity's sake.

The related components that are discussed are brightnucleus/dependencies and brightnucleus/settings. The configuration is loaded through brightnucleus/config.

Notable "features" of the below code:

View keybase.md

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:

You can’t perform that action at this time.