Skip to content

Instantly share code, notes, and snippets.

@everaldomatias
everaldomatias / contact-form-7-select-estados-shortcode.md
Last active November 30, 2018 16:24
Shortcode do plugin (WP) Contact Form 7 para select com os estados brasileiros.

[select* estados "AC" "AL" "AP" "AM" "BA" "CE" "DF" "ES" "GO" "MA" "MT" "MS" "MG" "PA" "PB" "PR" "PE" "PI" "RJ" "RN" "RS" "RO" "RR" "SC" "SP" "SE" "TO"]

SET @oldsite='http://localhost.com';
SET @newsite='http://producao.com.br';
UPDATE wp_options SET option_value = replace(option_value, @oldsite, @newsite) WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace(post_content, @oldsite, @newsite);
UPDATE wp_links SET link_url = replace(link_url, @oldsite, @newsite);
UPDATE wp_postmeta SET meta_value = replace(meta_value, @oldsite, @newsite);
UPDATE wp_posts SET guid = replace(guid, @oldsite, @newsite);
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var watch = require('gulp-watch');
var concat = require('gulp-concat');
var cleanCSS = require('gulp-clean-css');
sass.compiler = require('node-sass');
<?php
/**
* Add virtual page on WordPress hierarchy
* @link https://metabox.io/how-to-create-a-virtual-page-in-wordpress/
*/
add_filter( 'generate_rewrite_rules', function ( $wp_rewrite ){
$wp_rewrite->rules = array_merge(
['example/(\w+)/?$' => 'index.php?exp=$matches[1]'],
@everaldomatias
everaldomatias / register_post_type_labels.php
Last active September 12, 2019 17:40
WordPress register_post_type labels
<?php
[
'name' => __( '', '' ),
'singular_name' => __( '', '' ),
'add_new' => __( '', '' ),
'add_new_item' => __( '', '' ),
'edit_item' => __( '', '' ),
'new_item' => __( '', '' ),
'view_item' => __( '', '' ),
'view_items' => __( '', '' ),
@everaldomatias
everaldomatias / the_remove_wp_style.php
Created October 22, 2019 13:33
Função para remover um stylesheet do WordPress
<?php
/**
*
* Função para remover um stylesheet do WordPress.
* Por padrão o WordPress imprime o ID do style na tag <link> com um sufixo -css, exemplo 'theme-media-css', nesse caso o ID é apenas 'theme-media'
*
* @author Everaldo Matias <https://everaldo.dev>
* @uses Aplique no functions.php do seu tema (ou plugin)
* @since 20191022
@everaldomatias
everaldomatias / example-kirki-configuration.php
Last active January 16, 2020 20:01
Example for the Kirki WordPress Plugin configuration
<?php
/**
*
* Config, Panels, Sections and Fields by Kirki
*
* @link https://kirki.org/
* @author Everaldo Matias <https://everaldo.dev>
* @since 16/01/2020
* @version 1.0
if ( ! function_exists( 'auto_create_category' ) ) {
/**
*
* Create category with specific CPT is create or updated
*
* @author Everaldo Matias
* @link https://everaldo.dev
*
* @version 1.0
@everaldomatias
everaldomatias / the-file-size.php
Created May 17, 2020 23:52
WordPress function for get file size in attachment
if( !function_exists( 'the_file_size' ) ) {
/**
*
* WordPress function for get file size in attachment
*
* @author Everaldo Matias
* @link https://everaldo.dev
*
* @version 1.0
@everaldomatias
everaldomatias / wp-query-tax-meta.php
Created June 18, 2020 20:14
WordPress - Query posts with taxonomy term (NOT EXISTS) and meta value (DATE)
<?php
$args = [
'post_type' => 'events',
'posts_per_page' => -1,
'post_status' => 'publish',
'tax_query' => [
[
'taxonomy' => 'event_terms',
'field' => 'slug',
'terms' => 'event_past',