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:2bf444f0cc10bd06bf4e
Created March 31, 2015 09:23
WordPress Theme Activation/Deactivation hooks
<?php
/*
* Add this code to your theme's functions.php file
*/
// Theme activation
add_action("after_switch_theme", "theme_activated");
function theme_activation_hook(){
error_log('theme activated');
}
@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
@wp-kitten
wp-kitten / gist:2059737515145d947009
Created April 6, 2015 03:35
WordPress WP_QUERY args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
* 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 {{}}
*/
<?php
// v4.7.4
$vc_params_list = array(
// Default
'textfield',
'dropdown',
'textarea_html',
'checkbox',
'posttypes',
/*
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
}