Skip to content

Instantly share code, notes, and snippets.

View guilhermealveslopes's full-sized avatar

Guilherme Lopes guilhermealveslopes

View GitHub Profile
@guilhermealveslopes
guilhermealveslopes / Remove HTTP Wordpress Upload
Last active October 28, 2016 01:36
Remove HTTP Wordpress Upload
add_filter( 'wp_image_editors', 'change_graphic_lib' );
function change_graphic_lib($array) {
return array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' );
}
/* Add on functions.php */
@guilhermealveslopes
guilhermealveslopes / WC_purchased_items.txt
Last active July 4, 2017 11:42
Display last purchased products WooCommerce
<ul class="products">
<?php
$user_id = get_current_user_id();
$current_user= wp_get_current_user();
$customer_email = $current_user->email;
$args = array(
'post_type' => 'product',
'posts_per_page' => 12
);
$loop = new WP_Query( $args );
function add_theme_scripts() {
wp_enqueue_style( 'style', get_stylesheet_uri() );
wp_enqueue_style( 'css', get_template_directory_uri() . '/css/estilo.css', array(), '1.1', 'all');
wp_enqueue_script( 'script', get_template_directory_uri() . '/js/script.js', array ( 'jquery' ), 1.1, true);
}
add_action( 'wp_enqueue_scripts', 'add_theme_scripts' );
@guilhermealveslopes
guilhermealveslopes / Update MetaKey Value Wordpress
Created January 16, 2017 17:33
Update MetaKey from FrontEnd Submission Form Wordpress
function wpufe_update_post_price( $post_id ) {
$price = get_post_meta( $post_id, '_price', true );
update_post_meta( $post_id, '_regular_price', $price );
}
add_action( 'wpuf_add_post_after_insert', 'wpufe_update_post_price' );
add_action( 'wpuf_edit_post_after_update', 'wpufe_update_post_price' );
@guilhermealveslopes
guilhermealveslopes / Add All Brazilian Cities WP Database
Last active January 17, 2017 08:08
Para Criar taxonomia com todas as cidades brasileiras
INSERT INTO `wp_terms` (`term_id`, `name`, `slug`, `term_group`) VALUES
(63, 'AC', 'ac', 0),
(64, 'Acre', 'acre', 0),
(65, 'Acrelândia', 'acrelandia', 0),
(66, 'Assis Brasil', 'assis-brasil', 0),
(67, 'Brasiléia', 'brasileia', 0),
(68, 'Bujari', 'bujari', 0),
(69, 'Capixaba', 'capixaba', 0),
(70, 'Cruzeiro do Sul', 'cruzeiro-do-sul', 0),
@guilhermealveslopes
guilhermealveslopes / Share Product Woocommerce ADDTOANY
Created January 18, 2017 19:59
Share Product Woocommerce ADDTOANY
<ul class="products">
<?php
$user_id = get_current_user_id();
$current_user= wp_get_current_user();
$customer_email = $current_user->email;
$args = array(
'post_type' => 'product',
'posts_per_page' => 12
);
$loop = new WP_Query( $args );
function traduz_texto_wp( $translated ) {
$text = array(
'Exemplo' => 'Resultado',
'Exemplo' => 'Resultado',
'Exemplo' => 'Resultado',
);
$translated = str_ireplace( array_keys($text), $text, $translated );
return $translated;
}
add_filter( 'gettext', 'traduz_texto_wp', 20 );
@guilhermealveslopes
guilhermealveslopes / Metawp
Created February 14, 2017 01:00
Get Meta Wordpress
<?php echo get_post_meta( $post->ID, 'META', true); ?>
@guilhermealveslopes
guilhermealveslopes / JS Field repeat
Created February 14, 2017 11:56
JS Field repeat
$(document).ready(function(){
$('#primeiro').change(function() {
$('#segundo').val($('#primeiro').val());
});
});
/** Change text from $primeiro to $segundo after type **/
$(document).ready(function(){
$('#primeiro').keyup(function() {
$('#segundo').val($('#primeiro').val());
@guilhermealveslopes
guilhermealveslopes / Search & Filter Avada fix
Created March 15, 2017 17:22
Fix S&F result for Avada theme.
/* Duplicate and edit*/
/avada/search.php +/ /avada/search-filter-results.php
remove line 71-74 {
$post_timestamp = strtotime($post->post_date);
$post_month = date('n', $post_timestamp);
$post_year = get_the_date('o');
$current_date = get_the_date('o-n');
}