Skip to content

Instantly share code, notes, and snippets.

View pauloiankoski's full-sized avatar

Paulo Iankoski pauloiankoski

View GitHub Profile
@pauloiankoski
pauloiankoski / functions.php
Created August 5, 2015 11:51
Load prettyPhoto for the whole site
// LOAD PRETTY PHOTO for the whole site
add_action( 'wp_enqueue_scripts', 'frontend_scripts_include_lightbox' );
function frontend_scripts_include_lightbox() {
global $woocommerce;
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_script( 'prettyPhoto', $woocommerce->plugin_url() . '/assets/js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js', array( 'jquery' ), $woocommerce->version, true );
wp_enqueue_script( 'prettyPhoto-init', $woocommerce->plugin_url() . '/assets/js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js', array( 'jquery' ), $woocommerce->version, true );
@pauloiankoski
pauloiankoski / functions.php
Created July 22, 2015 18:28
Call action on submit wpcf7 form
add_action( 'wpcf7_submit', function( $contact_form, $result ) {
if ( empty( $result['status'] ) || 'mail_sent' != $result['status'] ) {
return;
}
$submission = WPCF7_Submission::get_instance();
if ( ! $submission || ! $posted_data = $submission->get_posted_data() ) {
return;
}
@pauloiankoski
pauloiankoski / front-page.php
Created July 9, 2015 01:22
Seção de Eventos do Arrase na Dança
<section id="events">
<h2 class="h1">Eventos</h2>
<?php
$args = array(
'category_name' => 'eventos',
'meta_key' => '_event_date',
'meta_query' => array(
array(
'compare' => '>=',
'key' => '_event_date',
@pauloiankoski
pauloiankoski / admin.php
Created July 3, 2015 02:37
Change Contact Form 7 submit button to BUTTON tag
//Fix Contact Form 7 Submit Button
remove_action( 'wpcf7_init', 'wpcf7_add_shortcode_submit', 20 );
add_action( 'wpcf7_init', 'wpcf7_add_shortcode_submit_button' );
function wpcf7_add_shortcode_submit_button() {
wpcf7_add_shortcode( 'submit', 'wpcf7_submit_button_shortcode_handler' );
}
function wpcf7_submit_button_shortcode_handler( $tag ) {
$tag = new WPCF7_Shortcode( $tag );
@pauloiankoski
pauloiankoski / gmaps_location.php
Created June 30, 2015 02:14
Retrieve Google Maps location with PHP
$address = sprintf( '%s,%s,%s,%s', $_POST['rua'], $_POST['bairro'], $_POST['cidade'], $_POST['estado'] );
$url = sprintf( 'http://maps.google.com/maps/api/geocode/json?address=%s&sensor=false&region=Brazil', urlencode( $address ) );
$response = wp_remote_get( $url );
if ( ! is_wp_error( $response ) ) {
$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
update_post_meta( $post_id, 'lat', $api_response['results'][0]['geometry']['location']['lat'] );
update_post_meta( $post_id, 'lng', $api_response['results'][0]['geometry']['location']['lng'] );
}
jQuery.extend(jQuery.validator.messages, {
required: "This field is required.",
remote: "Please fix this field.",
email: "Please enter a valid email address.",
url: "Please enter a valid URL.",
date: "Please enter a valid date.",
dateISO: "Please enter a valid date (ISO).",
number: "Please enter a valid number.",
digits: "Please enter only digits.",
creditcard: "Please enter a valid credit card number.",
@pauloiankoski
pauloiankoski / single-product.php
Created June 17, 2015 19:02
Antiga tabela de produtos da AZB
<?php
$tabela = array(
'calcio' => 'Cálcio (min./máx.)',
'fosforo' => 'Fósforo (min.)',
'enxofre' => 'Enxofre (min.)',
'sodio' => 'Sódio (min.)',
'cobalto' => 'Cobalto (min.)',
'cobre' => 'Cobre (min.)',
'iodo' => 'Iodo (min.)',
'selenio' => 'Selênio (min.)',
@pauloiankoski
pauloiankoski / teste.php
Created May 22, 2015 18:08
Apenas uma teste de integração
<section id="products">
<ul class="product-areas">
<?php
$areas_hierarchy = array();
$product_areas = get_terms( 'product_area' );
foreach( $product_areas as $key => $terms ) {
if( $terms->parent == 0 )
$areas_hierarchy[$terms->term_id]['current'] = $key;
else
$areas_hierarchy[$terms->parent]['child'][$terms->term_id] = $key;
@pauloiankoski
pauloiankoski / functions.php
Created February 11, 2015 12:24
Adiciona uma imagem padrão ao the_post_thumbnail
// Adiciona uma imagem padrão ao the_post_thumbnail
function add_default_image_to_the_post_thumbnail( $html, $post_id, $post_thumbnail_id, $size, $attr ) {
global $_wp_additional_image_sizes;
if( ! $post_thumbnail_id ) {
if( is_array( $_wp_additional_image_sizes[$size] ) ) {
$sizes['width'] = $_wp_additional_image_sizes[$size]['width'];
$sizes['height'] = $_wp_additional_image_sizes[$size]['height'];
} else {
$sizes['width'] = get_option( $size . '_size_w' );
@pauloiankoski
pauloiankoski / grid-shortcode.php
Created November 10, 2014 17:02
Add shortcode to use Bootstrap 3 grid system on WordPress admin editor.
// Add Shortcode
function shortcode_grid( $atts , $content = null ) {
$atts = shortcode_atts( array(
'open' => false,
'close' => false,
'cols' => '',
'offset' => '',
'class' => ''
), $atts );