Skip to content

Instantly share code, notes, and snippets.

View felipeelia's full-sized avatar

Felipe Elia felipeelia

View GitHub Profile
<?php
/**
* Add the input field to the form
*
* @param int $form_id
* @param null|int $post_id
* @param array $form_settings
*/
@felipeelia
felipeelia / wordpress-bulk-taxonomy-terms-delete.php
Created September 25, 2017 18:40
Delete ALL Terms In A Taxonomy (Use With Caution)
<?php
global $wpdb;
$taxonomy_slug = 'area';
$wpdb->query( "DELETE a, b, c, d
FROM {$wpdb->term_taxonomy} a
LEFT JOIN {$wpdb->terms} b
ON (a.term_id = b.term_id)
LEFT JOIN {$wpdb->term_relationships} c
@felipeelia
felipeelia / atom-auto-update.sh
Last active October 16, 2017 15:44
Update Atom to lastest stable release
#!/bin/bash
set -euo pipefail
# from this answer: https://askubuntu.com/a/630530/700841
# with some changes, like testing versions, for instance.
#
# How to use:
# 1. put this at /usr/local/bin/ as atom-auto-update (without .sh)
# 2. save and make it executable with `sudo chmod +x /usr/local/bin/atom-auto-update`
# 3. run whenever you want with `sudo atom-auto-update`
@felipeelia
felipeelia / wpdockerinstall.sh
Created October 22, 2017 00:23
Instalação automatizada do WordPress em pt-BR com WP-CLI e bash em docker. Ver também: https://gist.github.com/EliaBR/199f7e1356c63cab88b25710286414b1
export wp_docker='sudo docker exec -i docker_wordpress_1 wp'
export DB_HOST="mysql"
export DB_USER="wordpress"
export DB_PASS="wordpress"
export DB_NAME="wordpress"
export DOCKER_INST=1
source $( dirname "${BASH_SOURCE[0]}" )/wpinstall.sh
@felipeelia
felipeelia / wordpress-bulk-posts-delete-by-post-type.sql
Created October 26, 2017 21:29
Delete ALL Posts, Meta and Terms Relationship of a Certain Post Type (Use With Caution)
DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id )
LEFT JOIN wp_postmeta c ON ( a.ID = c.post_id )
WHERE a.post_type = '<POST_TYPE>'
@felipeelia
felipeelia / snippets.cson
Created December 10, 2017 20:05
Meus snippets no Atom
'.text.html':
'WP Plugin - empty index':
'prefix': 'plugin_index'
'body': """
<?php
// Silence is golden
"""
'WP Plugin - new plugin':
'prefix': 'plugin_file'
'body': """
@felipeelia
felipeelia / forum.html
Last active April 20, 2018 19:16 — forked from claudiosanches/forum.html
Forum
<h2 id="bem-vindos-ao-forum-de-suporte">Bem-vindo(a) ao fórum de suporte <a href="#bem-vindos-ao-forum-de-suporte">#</a></h2>
Esta página é uma mensagem de boas-vindas aos <a href="https://br.wordpress.org/support/">fóruns de suporte</a> do WordPress do Brasil. Esperamos que este documento seja útil para você, uma vez que é destinado a ser um manual de "começo rápido" ao invés de uma documentação completa. Esta introdução feita para que você possa encontrar o seu caminho pelo fórum e comece a usá-lo o mais rápido possível. <!-- Para encontrar informações detalhadas e completas sobre o fórum, acesse o artigo [[pt-br:Usando_o_Fórum_de_Suporte|Utilizando os fóruns de suporte]] do Codex. -->
Antes de publicar, tenha certeza de que está publicando sobre um site que utiliza o WordPress.org e <strong>NÃO</strong> o WordPress.com. Caso você não tenha certeza, leia o artigo <a href="https://br.support.wordpress.com/com-vs-org/">WordPress.com e WordPress.org</a> para entender a diferença.
Estes fóruns são destinados
<?php
/**
* The public-facing functionality of the plugin.
*
* @link https://dualcon.ddns.net/
* @since 1.0.0
*
* @package My_Wp_Tools
* @subpackage My_Wp_Tools/public
@felipeelia
felipeelia / db-backup.php
Created October 3, 2018 18:38
Generate a dump from a WordPress website
<?php
include 'wp-config.php';
ini_set( 'display_errors', 1 );
ini_set( 'display_startup_errors', 1 );
error_reporting( E_ALL );
$dir = dirname( __FILE__ ) . '/dump.sql';
echo "<h3>Backing up database to `<code>{$dir}</code>`</h3>";
@felipeelia
felipeelia / fetch-from-wp-rest-api.php
Last active September 15, 2019 19:15
Given a WP REST API content list route, fetches all IDs, URLs, and Titles into a CSV file.
<?php
/**
* Usage example: `php -f fetch-from-wp-rest-api.php https://wordpress.org/support/wp-json/wp/v2/articles helphub-list`
*/
$first_page = file_get_contents( $argv[1] . '?per_page=100' );
$first_page_headers = parse_headers( $http_response_header );
$content = json_decode( $first_page, true );
for ( $i = 2; $i < $first_page_headers['X-WP-TotalPages']; $i++ ) {