Skip to content

Instantly share code, notes, and snippets.

View allysonsouza's full-sized avatar
💻
Doing some WordPress stuff...

Allyson Souza allysonsouza

💻
Doing some WordPress stuff...
View GitHub Profile
@allysonsouza
allysonsouza / functions.php
Created October 10, 2018 19:47
Custom icon in WordPress admin menu
<?php
function my_custom_post_type() {
register_post_type('labs', [
'label' => 'Labs',
'menu_icon' => 'data:image/svg+xml;base64,' . base64_encode('<svg width="20" height="20" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path fill="black" d="M1591 1448q56 89 21.5 152.5t-140.5 63.5h-1152q-106 0-140.5-63.5t21.5-152.5l503-793v-399h-64q-26 0-45-19t-19-45 19-45 45-19h512q26 0 45 19t19 45-19 45-45 19h-64v399zm-779-725l-272 429h712l-272-429-20-31v-436h-128v436z"/></svg>')
]);
}
add_action( 'init', 'my_custom_post_type' );
@allysonsouza
allysonsouza / .gitignore
Last active January 27, 2020 01:35
.gitignore template for WordPress
# WORDPRESS
# Exclude WordPress core folders and root files.
wp-admin/
wp-includes/
*.php
# WP-CONTENT
# Ignore all wp-content, except for specified folders.
wp-content/*
!wp-content/haste/
@allysonsouza
allysonsouza / .deployignore
Last active September 11, 2019 19:16
DeployHQ - Modelo de .deployignore para WordPress
## WORDPRESS CORE FOLDERS
wp-admin/**
wp-includes/**
## WORDPRESS CONTENT
wp-content/languages/**
wp-content/upgrade/**
wp-content/uploads/**
wp-content/index.php
@allysonsouza
allysonsouza / woocommerce-pre-get-posts.php
Last active November 2, 2023 09:08
[Custom filter by price with pre_get_posts] #woocommerce
<?php
function woocommerce_pre_get_posts( $query ) {
if ( ! is_admin() && is_post_type_archive( 'product' ) && $query->is_main_query() ) {
// Option 1
$args = array(
array(
'meta_key' => '_price',
@allysonsouza
allysonsouza / db-update.bat
Last active August 22, 2018 06:30
Connect to your server trough ssh and run wp-cli commands in an automated way in Windows
:: Name: db-update.bat
:: Purpose: Connect to server trough ssh and run wp-cli commands
:: Author: @allysonsouza
:: URL: https://github.com/allysonsouza
:: Version: 0.0.1
:: License: GPL-v2
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
@allysonsouza
allysonsouza / Clearfile.bat
Created June 1, 2018 01:28
Clear a file content, accepting two parameters: filepath and filename
echo off
set filepath=%1
set filename=%2
break > %filepath%\%filename%
@allysonsouza
allysonsouza / wpml-kirki.php
Created April 26, 2018 15:57
Creating fields for each language in customizer with Kirki and WPML
<?php
if( function_exists( 'icl_get_languages' ) ) {
$languages = icl_get_languages( 'skip_missing=N&orderby=KEY&order=DIR&link_empty_to=str');
}
if( !empty( $languages ) ) {
foreach( array_reverse( $languages ) as $lang ) {
Kirki::add_field( 'daibase', array(
'settings' => 'field_' . $lang['code'],
@allysonsouza
allysonsouza / banana-replace.php
Created December 2, 2017 07:15
Workshop: Desenvolvendo seu primeiro plugin
<?php
/*
Plugin Name: Banana Replace
Plugin URI: 2017.saopaulo.wordcamp.org
Description: Substitui a palavra banana por um gif
Version: 1.0
Author: Eu
Author URI: https://wordpress.org/
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@allysonsouza
allysonsouza / webpack.config.js
Created October 2, 2017 15:01
WebPack for WordPress Theme
// Const
const webpack = require('webpack'); //to access built-in plugins
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const path = require('path');
// ExtractPlugin - Multiple instances
// Configure individual stylesheet generation to use correctly with wp_enqueue_style
const extractMain = new ExtractTextPlugin('css/main.min.css');
const extractAdmin = new ExtractTextPlugin('css/admin.min.css');
const extractEditor = new ExtractTextPlugin('css/editor.min.css');
@allysonsouza
allysonsouza / web-stack.bat
Created September 15, 2017 15:31
Windows Start Programs Batch
@echo off
:: Change to match your program's paths
start "XAMPP" "C:\xampp\xampp-control.exe"
start "Atom" "C:\Users\[MYUSER]\AppData\Local\atom\atom.exe"
start "SourceTree" "C:\Program Files (x86)\Atlassian\SourceTree\SourceTree.exe"
start "Cmder" "C:\Users\[MYUSER]\Downloads\cmder\cmder.exe"
exit