Skip to content

Instantly share code, notes, and snippets.

View felipeelia's full-sized avatar

Felipe Elia felipeelia

View GitHub Profile
@tott
tott / group-fields.php
Last active September 27, 2022 13:26
ElasticPress group meta fields
<?php
add_filter(
'ep_prepare_meta_data',
function ( $meta ) {
$meta_groups = [
'group1' => [
'_sku',
'_sale_price_dates_from',
'_sale_price_dates_to',
],
@mariovalney
mariovalney / script.php
Created December 4, 2019 17:29
Turn exported WooCommerce/WordPress Orders into CSV file
<?php
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=file.csv");
header("Pragma: no-cache");
header("Expires: 0");
// Load file
$xml_string = file_get_contents(dirname(__FILE__) . '/file.xml');
str_replace($xml_string, 'dc:', 'dc-');
@mariovalney
mariovalney / pre-commit
Last active January 31, 2025 19:28
Pre-commit hook to check code with PHPCS, fix with PHPCBF and check mess with PHPMD
#!/bin/sh
#########################
# #
# Initializing #
# #
#########################
##
# You should add all tools as composer dependencies or change this path
#!/bin/bash
# If you find a site with /_wpeprivate/config.json file exposed, run this and get all kinds of fun goodies.
# If it "no worked" (Technical Term) then you probably need to install jq!
TARGET=$1
TARGETDOMAIN=$(echo $TARGET | cut -d/ -f3)
# Pretty Colors
RESET='\033[00m'
GREEN='\033[01;32m'
@mariovalney
mariovalney / load-csv-to-database.php
Last active May 20, 2019 14:20
LOAD DATA from file to Database
<?php
/**
* Adding data to table using CSV data
* Using WPDB in WordPress but you can use any PHP...
*
* @link https://dev.mysql.com/doc/refman/5.7/en/load-data.html
*/
global $wpdb;
@marcelod
marcelod / gist:74162a499b13f4490587c771774bfb77
Last active September 14, 2020 13:09
Deploy com git automatizado

Parte do servidor

  • acessar via ssh o servidor, por exemplo ssh user@ip
  • no servidor, acessar a pasta do projeto, por exemplo, /var/www/meu-projeto/
  • criar e acessar a pasta, por exemplo app.git (mkdir app.git && cd app.git)
  • dentro de app.git, executar o comando git init --bare para criar um repositório mínimo git
  • criar um arquivo chamado post-receive dentro de app.git/hooks - nano hooks/post-receive e adicionar o seguinte conteúdo
#!/bin/sh
@rafael-neri
rafael-neri / validar_cpf.php
Last active February 11, 2025 20:23
Validar CPF em PHP (Completo)
<?php
function validaCPF($cpf) {
// Extrai somente os números
$cpf = preg_replace( '/[^0-9]/is', '', $cpf );
// Verifica se foi informado todos os digitos corretamente
if (strlen($cpf) != 11) {
return false;
@kellenmace
kellenmace / get-post-types-by-taxonomy-in-wordpress.php
Created June 16, 2016 14:39
Get Post Types by Taxonomy in WordPress
<?php
/**
* Get all post types for a taxonomy.
*
* @author Kellen Mace
* @param string $taxonomy The taxonomy slug to get post types for.
* @return array The post types associated with $taxonomy.
*/
function wds_campbell_get_post_types_by_taxonomy( $taxonomy = '' ) {
@remyperona
remyperona / gist:13348dbcd2bbb0d9406f
Created April 14, 2015 14:32
WordPress customizer custom tinymce control
class Text_Editor_Custom_Control extends WP_Customize_Control
{
public $type = 'textarea';
/**
** Render the content on the theme customizer page
*/
public function render_content() { ?>
<label>
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
<?php