Skip to content

Instantly share code, notes, and snippets.

View load-mu-plugins-from-dirs.php
<?php
$flags = \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS;
$iterator = new \FilesystemIterator(__DIR__, $flags);
foreach ($iterator as $path => $item) {
if ($item->isDir()) {
$muPath = trailingslashit($path);
$fileName = basename($item->getFileName());
$filePath = "{$muPath}/{$fileName}.php";
@awps
awps / ContactFormProcessing.php
Last active Dec 16, 2018
A very simple, yet complete, AJAX contact form for WordPress.
View ContactFormProcessing.php
<?php
class ContactFormProcessing
{
protected $action = 'example_contact_form';
public function ajaxInit()
{
add_action("wp_ajax_{$this->action}", [$this, 'process']);
add_action("wp_ajax_nopriv_{$this->action}", [$this, 'process']);
}
View everyTimeFrame.php
<?php
function everyTimeFrame($totalMinutes = 4, $lastSeconds = 16)
{
$time = [];
for ($i = 0; $i <= 59; $i++) {
for ($j = 0; $j <= $totalMinutes; $j++) {
$second = strlen($i) > 1 ? $i : "0{$i}";
View slider.js
import Util from './util'
import Swipe from './swipe'
class Slider {
constructor( slider_el, options = {} ) {
// Default options
this.opt = {
inactiveClass: 'inactive-slide',
speed: 5000,
startAt: 0,
View Person.js
class Person {
constructor($name){
this._name = $name;
}
getName(){
return `Hello ${this._name}`;
}
}
View money-array-description.php
<?php
return array(
'EUR' => [ 'Euro', '&euro;' ],
'USD' => [ 'US dollar', '&#36;' ],
'JPY' => [ 'Japanese yen', '&yen;' ],
'BGN' => [ 'Bulgarian lev', '&#1083;&#1074;.' ],
'CZK' => [ 'Czech koruna', '&#75;&#269;' ],
'DKK' => [ 'Danish krone', 'DKK' ],
'GBP' => [ 'Pound sterling', '&pound;' ],
@awps
awps / money.php
Created Mar 7, 2018
Currency symbols PHP ARRAY(probably all that exists)
View money.php
<?php
return [
'AED' => '&#x62f;.&#x625;',
'AFN' => '&#x60b;',
'ALL' => 'L',
'AMD' => 'AMD',
'ANG' => '&fnof;',
'AOA' => 'Kz',
'ARS' => '&#36;',
View sticky-menu.js
// Source: https://gist.github.com/Smartik89/c6b096d82956c777079ba04a3d14d12d/
function smk_menu_sticky( _menu, _sticky_class, _container, _top ){
_container = _container || window;
_sticky_class = _sticky_class || 'sticky-menu';
_menu = _menu || '.main-menu';
_top = _top || 300;
$( _container ).scroll(function () {
if ($(this).scrollTop() > _top) {
$( _menu ).addClass( _sticky_class );
View wgt.php
<?php
/*-----------------------------------------------------------
- Name: Options Widget
- Description: Test SMK Toolkit
- Version: 1.0
-------------------------------------------------------------*/
if( ! class_exists('Options_Widget') && class_exists('SMK_Toolkit_Widget') ) {
class Options_Widget extends SMK_Toolkit_Widget {
/*-----------------------------------------------------------