Skip to content

Instantly share code, notes, and snippets.

View wp-kitten's full-sized avatar

Costin wp-kitten

View GitHub Profile
@wp-kitten
wp-kitten / gist:ff5164df5caecf8640047a3ae981fa94
Created January 3, 2023 21:10
Remove "public" from URL for Laravel websites
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1 [L,QSA]
---
This will silently rewrite all your base URIs to the /public folder.
Even all Headers, for example the HTTP Authorization Header, and all
optional URI parameters will silently be passed on to the /public folder as well.
Applies to web hosts that do not allow to change the home directory.
@wp-kitten
wp-kitten / gist:40e2d711e63e1f5f31fa660061fe82fd
Last active June 24, 2021 02:05
WordPress-like actions for javascript
/**
* Global object storing all registered actions
* @type {*[]}
* @public
*/
window.__actions__ = [];
/**
* Register an action
* @param actionName
@wp-kitten
wp-kitten / .htaccess
Created April 24, 2020 07:45
Localhost Laravel app 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 /
@wp-kitten
wp-kitten / gist:c22d5e57427c81c2a0310c667acf5bba
Created December 3, 2019 15:06
Install Redis for windows
https://github.com/microsoftarchive/redis/ => get redis installer for windows
to use redis as cache service, install predis:
>> composer require predis/predis
* 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 October 7, 2018 15:15
Utility object to add wp-like actions
(function ($) {
"use strict";
/**
* Holds the list of all registered actions
* @see this.addAction
* @see this.hasAction
* @see this.doAction
* @type {{}}
*/
/*
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 September 29, 2018 11:25 — forked from liconti/rrmdir.php
PHP recursive rmdir
<?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 August 16, 2018 04:11 — 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
<?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 July 21, 2018 09:30
Override WooCommerce from plugin

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: