Skip to content

Instantly share code, notes, and snippets.

@warderer
warderer / package.json
Created September 20, 2021 18:25
[Webpack config starter] Basic Webpack Scaffold (clean) and a complete template example with HTML, Babel, CSS, SASS, Image Support, Live Reloading and DevServer with setup instructions #webpack #config #js #package.json #webpack.config.js
/* En el package.json añadir en la parte de scripts los siguientes*/
"scripts": {
"build": "webpack --mode=production",
"start:dev": "webpack-dev-server"
},
@warderer
warderer / functions.php
Last active September 13, 2021 22:02
[Wordpress: Load custom JS in Child Theme] from functions.php in all pages or specific ones #wordpress #js
#Inserting an <script> tag in header.php or footer.php template files isn't recommended, because Wordpress handles the loading sequence of scripts and css files in a different way and may cause issues with some plugins/themes. This is the correct way to enqueue any type of script in WordPress:
#Considering using this code in the functions.php child theme file.
function custom_load_js_script() {
// array of page id numbers, titles or slugs
// the scripts only be loaded in selected pages, if you remove the "if" statement they will be loaded in all pages.
if( is_page(array('10', '1595', '1099', '1518') ) ) {
//Load from an external resource, the first parameter is an identifier and must be unique, the last "true" sets if this script should load at footer (if false, it's loaded in header).
wp_enqueue_script( 'ext-js-file', 'https://d1gwclp1pmzk26.cloudfront.net/myexamplescript.js', null, null, true );
@warderer
warderer / functions.php
Last active February 11, 2025 22:02
[Remove Activation Notice Ultimate Addons for Visual Composer] As a theme developer who bundles Visual Composer (now WP Bakery) and use Ultimate Addons for Visual Composer ith your theme you’re going to want to disable the activation notice for your end users. Add code to the theme functions.php #wordpress #VisualComposer #WPBakery
//Credits: https://sharewebdesign.com/blog/remove-activation-notice-ultimate-addons-for-visual-composer/
//Disable End User Admin Notification Message
//“Please activate your copy of the Ultimate Addons for Visual Composer to get update notifications, access to support features & other resources!”
define('BSF_PRODUCTS_NOTICES', false);
//Also you’ll probably want to disable the activation notice for Visual Composer itself:
vc_set_as_theme( $disable_updater = true );
@warderer
warderer / powershell.txt
Created July 12, 2021 21:55
[Windows Powershell Rename] Replace characters inside the current folder on Windows Powershell
Dir | Rename-Item -NewName { $_.Name -replace "Special char","" }
@warderer
warderer / SheetsToCalendar.gs
Last active June 17, 2021 19:13
[Google Spreadsheet Events to Google Calendar] Google App Script to use in Google Spreadsheets to Connect with a Calendar #apps-script #calendar #spreadsheet #google
/*
Google Apps Script para Google Spreadsheet
Versión que necesita indicarle fecha/hora de inicio, fecha/hora de fin y titulo
Autor: César Guerra - www.cesarguerra.mx
Fecha: 05-06-2021
*/
function SheetsToCalendar() {
// 0.- Setup
const spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); // Hoja con la info de eventos
@warderer
warderer / useForm.js
Created April 15, 2021 23:53
[useForm React] React hook to handle inputs values #react #hooks
// REGLAS PARA CREAR MIS PROPIOS HOOKS
// 1. siempre llamarlo useLoQueSea ej useForm
// 2. SIEMPRE deben ser funciones !!!!!!!
// 3. Tienes que utilizar hooks de react, y no deben estar loops, condiciones o funciones anidadas
// LOS HOOKS TINEN QUE SER UNIVERSALES
import {useState} from 'react';
function useForm(callback, defaults){
const [inputs,setInputs] = useState(defaults) // aqui vamos a estar guardando los valores de mis formularios
const handleSubmit = (event) => {
@warderer
warderer / .htaccess
Created April 6, 2021 04:42
[htaccess complete starter template] Best practices with a complete configurable .htaccess file for starter web projects. Some pieces of code like the cache expiration could be used in #wordpress
# Author URL: https://github.com/h5bp/html5-boilerplate/blob/master/dist/.htaccess
# Apache Server Configs v4.1.0 | MIT License
# https://github.com/h5bp/server-configs-apache
# (!) Using `.htaccess` files slows down Apache, therefore, if you have
# access to the main server configuration file (which is usually called
# `httpd.conf`), you should add this logic there.
#
# https://httpd.apache.org/docs/current/howto/htaccess.html
@warderer
warderer / functions.php
Last active September 13, 2021 21:49
[Wordpress: Redirect to login if user isn´t logged on certain page] Redirect function in theme functions.php #wordpress
/* Si no estoy logeado en la página indicada, redirigeme al login */
add_action( 'template_redirect', function() {
if ( is_page('slug-de-pagina') && ! is_user_logged_in() ){
wp_redirect( site_url( '/login' ) );
exit();
}
});
@warderer
warderer / robots.txt
Last active April 1, 2021 18:59
[Robots.txt on Wordpress] with sitemap from Joast SEO #wordpress
User-agent: *
Disallow: /home/wp-admin/
Allow: /home/wp-admin/admin-ajax.php
# Disable search indexing
Disallow: /?s=
Disallow: /search/
#Sitemap URL
Sitemap: https://www.mysite.com/sitemap_index.xml
@warderer
warderer / .gitignore
Last active March 30, 2024 01:14
[GitIgnore] Standard .gitignore configuration for Node JS Express projects #nodejs #expressjs #git
# Created by César Guerra - www.cesarguerra.mx
# Gist at: https://go.cesarguerra.mx/gitignore
# env files
.env
.env.local
.env.*.local
# npm
node_modules