Skip to content

Instantly share code, notes, and snippets.

View awps's full-sized avatar
🎯
Focusing

Andrei Surdu awps

🎯
Focusing
View GitHub Profile
@awps
awps / wgt.php
Created December 19, 2013 23:27
<?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 {
/*-----------------------------------------------------------
// 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 );
@awps
awps / money.php
Created March 7, 2018 17:31
Currency symbols PHP ARRAY(probably all that exists)
<?php
return [
'AED' => '&#x62f;.&#x625;',
'AFN' => '&#x60b;',
'ALL' => 'L',
'AMD' => 'AMD',
'ANG' => '&fnof;',
'AOA' => 'Kz',
'ARS' => '&#36;',
<?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;' ],
class Person {
constructor($name){
this._name = $name;
}
getName(){
return `Hello ${this._name}`;
}
}
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,
<?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}";
@awps
awps / ContactFormProcessing.php
Last active December 16, 2018 17:38
A very simple, yet complete, AJAX contact form for WordPress.
<?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']);
}
<?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 / PostBlocks.php
Created December 10, 2021 10:50
How to modify the Gutenberg blocks from post content with PHP
<?php
namespace ZeroWP;
class PostBlocks
{
/**
* @param \WP_Post|int $post
* @param callable $callback
*