Skip to content

Instantly share code, notes, and snippets.

View camaleaun's full-sized avatar

Gilberto Tavares camaleaun

  • Yogh
  • Joinville SC, Brazil
  • 00:18 (UTC -03:00)
View GitHub Profile
alias wpdebug0='wp config set WP_DEBUG false --raw --type=constant'
alias wpdebug1='wp config set WP_DEBUG true --raw --type=constant'
alias rmdss='find . -name '.DS_Store' -type f -delete'
alias rmnm='find . -name 'node_modules' -type d -delete'
alias rmcv='find . -name 'vendor' -type d -delete'
alias guiau='git update-index --assume-unchange'
alias guinau='git update-index --no-assume-unchange'
alias jpdev1='wp config set JETPACK_DEV_DEBUG true --type=constant --raw'
alias jpdev0='wp config set JETPACK_DEV_DEBUG false --type=constant --raw'
alias wplangupdate='wp language core update && wp language plugin update --all && wp language theme update --all'
@camaleaun
camaleaun / formatting.php
Last active January 26, 2019 13:31
Formatting functions
/**
* Extract full name to first and last name.
*
* @version 1.0.1
* @link https://gist.github.com/camaleaun/a9ab8de21dd9830708f927b6db69c021
* @param string $name Full name.
* @param string $object Optional. If true return as OBJECT (with 'first' and 'last' as properties) (Default ARRAY_N).
* @return array|object First and last names.
*/
function pluginname_split_name( $name, $object = false ) {
@camaleaun
camaleaun / pluginname.php
Created November 20, 2018 13:32
Register commands to run through WP-CLI
if ( defined( 'WP_CLI' ) && WP_CLI ) {
WP_CLI::add_hook( 'after_wp_load', 'pluginname_cli_runner' );
}
function pluginname_test() {
WP_CLI::success( 'Command works.' );
}
function pluginname_cli_runner() {
WP_CLI::add_command( 'pluginname test', 'pluginname_test' );
}
@camaleaun
camaleaun / functions.php
Last active November 25, 2019 16:43
Remove accents, lowercase and underscores to dashes
<?php
add_filter( 'sanitize_file_name', 'themename_sanitize_file_name' );
/**
* Remove accents, maybe lowercase and underscores to dashes
*
* @version 1.0.4
* @link https://gist.github.com/camaleaun/d8d12d04ff879a89d833c9eb39362eda
* @param string $filename Name of file.
* @return string Sanitized file name.
@camaleaun
camaleaun / tab-trigger.js
Created September 13, 2018 14:58 — forked from wesbos/tab-trigger.js
How to properly get a TAB trigger working with Emmet inside of JSX
{
"keys": ["tab"],
"command": "expand_abbreviation_by_tab",
// put comma-separated syntax selectors for which
// you want to expandEmmet abbreviations into "operand" key
// instead of SCOPE_SELECTOR.
// Examples: source.js, text.html - source
"context": [
{
@camaleaun
camaleaun / chat.html
Created July 31, 2018 18:23
Hsform hack to redirects to HypnoBx chat
<!--[if lte IE 8]>
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"></script>
<![endif]-->
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
<script>
hbspt.forms.create({
portalId: "PORTAL_ID_HERE",
formId: "FORM_ID_HERE"
});
var chatData = {};
add_action( 'init', 'short_aliases' );
add_filter( 'short_aliases', 'shorts_redirect' ) );
function short_aliases() {
$aliases = apply_filters( 'short_aliases', array() );
if ( ! is_array( $aliases ) ) {
$aliases = array();
}
foreach ( $aliases as $alias => $redirects ) {
add_rewrite_rule( "^$alias/?", $redirects, 'top' );
@camaleaun
camaleaun / wp-api_inspector.html
Last active July 5, 2018 17:29
Inspector to WordPress rest API with fetch and Vue.js
<!DOCTYPE html>
<html>
<head>
<title>WordPress Inspector</title>
<meta charset="utf-8">
<link rel="icon" href="https://visie.com.br/favicon.ico">
<style>
body {
margin: 0;
padding: 0;
@camaleaun
camaleaun / mysqldump.php
Last active June 27, 2018 13:10
Dump wp database by file
<?php
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', dirname( __FILE__ ) . '/' );
}
error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
if ( file_exists( ABSPATH . 'wp-config.php') ) {
@camaleaun
camaleaun / functions.php
Created June 5, 2018 20:14
Function to wc myaccount navigation add
add_filter( 'woocommerce_account_menu_items', 'daico_account_menu_items2' );
function daico_account_menu_items2( $items ) {
unset( $items['customer-logout'] );
$items['orders'] = 'Vendas';
$items['customer-logout'] = 'Sair';
return $items;
}