Skip to content

Instantly share code, notes, and snippets.

Avatar

Costin wp-kitten

View GitHub Profile
@wp-kitten
wp-kitten / gist:40e2d711e63e1f5f31fa660061fe82fd
Last active Jun 24, 2021
WordPress-like actions for javascript
View gist:40e2d711e63e1f5f31fa660061fe82fd
/**
* Global object storing all registered actions
* @type {*[]}
* @public
*/
window.__actions__ = [];
/**
* Register an action
* @param actionName
@wp-kitten
wp-kitten / .htaccess
Created Apr 24, 2020
Localhost Laravel app htaccess
View .htaccess
#
# Local .htaccess file
# Used to set the "public" directory as the document root
### laravel App (https://laravel-site.dev/)
#
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
View gist:c22d5e57427c81c2a0310c667acf5bba
https://github.com/microsoftarchive/redis/ => get redis installer for windows
to use redis as cache service, install predis:
>> composer require predis/predis
View [CUSTOM SETUP] webpack for react + sass
* The least working version for Custom Build React app + scss
* Not all entries in package.json are required && can be improved
=============================================================================
(npm run build or npx webpack)
=============================================================================
-----------------------------
package.json
-----------------------------
@wp-kitten
wp-kitten / gist:60f297331a716b8ccef90944a1a6c51e
Created Oct 7, 2018
Utility object to add wp-like actions
View gist:60f297331a716b8ccef90944a1a6c51e
(function ($) {
"use strict";
/**
* Holds the list of all registered actions
* @see this.addAction
* @see this.hasAction
* @see this.doAction
* @type {{}}
*/
View Best scroll into view script
/*
usage: scrollToElm($containerElement.get(0), $targetItem.get(0), 0.2);
url: https://stackoverflow.com/a/51005649
*/
function scrollToElm(container, elm, duration) {
var pos = getRelativePos(elm);
scrollTo(container, pos.top, duration); // duration in seconds
}
@wp-kitten
wp-kitten / rrmdir.php
Created Sep 29, 2018 — forked from liconti/rrmdir.php
PHP recursive rmdir
View rrmdir.php
<?php
function rrmdir($path){
if (is_dir($path)) {
array_map( "rrmdir", glob($path . DIRECTORY_SEPARATOR . '{,.[!.]}*', GLOB_BRACE) );
@rmdir($path);
}
else {
@unlink($path);
}
}
@wp-kitten
wp-kitten / rh-get-widget-data-for-all-sidebars.php
Created Aug 16, 2018 — forked from kingkool68/rh-get-widget-data-for-all-sidebars.php
WordPress function to get raw widget data for all of the widgets in a given sidebar
View rh-get-widget-data-for-all-sidebars.php
<?php
function rh_get_widget_data_for_all_sidebars() {
global $wp_registered_sidebars;
$output = array();
foreach ( $wp_registered_sidebars as $sidebar ) {
if ( empty( $sidebar['name'] ) ) {
continue;
}
$sidebar_name = $sidebar['name'];
@wp-kitten
wp-kitten / gist:e2d2a8588b5ce772162453204674c7ce
Last active Jul 21, 2018
Override WooCommerce from plugin
View gist:e2d2a8588b5ce772162453204674c7ce

https://www.skyverge.com/blog/override-woocommerce-template-file-within-a-plugin/

The normal WooCommerce template loader searches the following locations in order, until a match is found:

  • your theme / template path / template name
  • your theme / template name
  • default path / template name

We’re going to alter this slightly by injecting a search for the template within our own custom plugin (step 3 below), before finally defaulting to the WooCommerce core templates directory:

View gist:deee20bd58a8e94fcc6746d190b5d251
'use strict';
const AWS = require('aws-sdk');
const s3 = new AWS.S3({signatureVersion: 'v4'});
exports.handler = (event, context, callback) => {
const bucket = process.env['s3_bucket'];
if (!bucket) {
callback(new Error(`S3 bucket not set`));
}