Skip to content

Instantly share code, notes, and snippets.

View schlessera's full-sized avatar

Alain Schlesser schlessera

View GitHub Profile
@schlessera
schlessera / README.md
Created July 29, 2016 14:20
Real-time Log Viewer Example

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:

@schlessera
schlessera / Controller.php
Last active November 5, 2020 13:31
Example of bootstrapping a WordPress plugin.
<?php
// file: src/Controller.php
/**
* Example Plugin Controller.
*/
namespace Example\Plugin;
use BrightNucleus\Config\ConfigInterface;
@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;
@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 / _reflowing-columns.scss
Created April 23, 2015 16:52
Reflowing columns (CSS Multi-column)
/**
* Reflowing columns (CSS Multi-column)
*
* This defines reflowing columns in CSS. Simply apply the class with the number
* of columns you need, like .reflow-3 . The number of columns wil be reduced if
* the individual columns go below $min-column-width.
*
* IE10+ only, all but Firefox have trouble displaying <li>s inside the columns.
*
* @author Alain Schlesser <alain.schlesser@gmail.com>