Skip to content

Instantly share code, notes, and snippets.

View javierarques's full-sized avatar

Javier javierarques

View GitHub Profile
@javierarques
javierarques / index.html
Created June 18, 2014 07:45
A Pen by Javier.
<div class="table container">
<div class="table-cell">
<code>display: table-cell;</code>
</div>
</div>
<div class="wrapper container">
<div class="inline-block">
<code>display: inline-block;</code>
</div>
@javierarques
javierarques / header.php
Created June 13, 2014 10:45
WPML / Wordpress custom switch language menu adapted for Zurb Foundation 5 top bar menu
<?php if ( function_exists('icl_get_languages')):?>
<?php
$languages = icl_get_languages('skip_missing=N');
$active = $languages[ICL_LANGUAGE_CODE];
echo '<li class="has-dropdown"><a href="#">'.
'<i class="icon-'.ICL_LANGUAGE_CODE.' flag"></i>'.
'</a>';
if(!empty($languages)){
echo '<ul class="dropdown">';
@javierarques
javierarques / functions.php
Created June 2, 2014 18:50
[Wordpress] Get the term names of a post
/**
* Retrieve a post's terms as a list with specified format.
*
* @since 2.5.0
*
* @param int $id Post ID.
* @param string $taxonomy Taxonomy name.
* @param string $before Optional. Before list.
* @param string $sep Optional. Separate items using this.
* @param string $after Optional. After list.
@javierarques
javierarques / functions.php
Last active August 29, 2015 14:02
Function the_weather.Wordpress weather box from openweathermap.org API. The API resutls are cached a day with Wordpress Transient API.
/**
* Returns a cached json object with forecast info of a city
* forecast info from openweathermap.org api
* you need and API key
*
* @param $city string with city name
* @return mixed|string json object with forecast info
*/
function get_city_weather( $city ) {
/**
@javierarques
javierarques / app.js
Last active December 15, 2022 21:13
Custom taxonomy dropdown walker
$(".goToCategory").change( function() {
if ( this.options[this.selectedIndex].value !== 0 ) {
location.href = this.options[this.selectedIndex].getAttribute('data-permalink');
}
});
@javierarques
javierarques / share-demo-plugin.php
Created May 18, 2014 08:20
Ejemplo de plugin simple
<?php
/*
Plugin Name: Compartir Demo Plugin
Description: Este plugin es un ejemplo de creación de plugin para el postgrado ID3 con el cual se puede compartir un post en las redes sociales
Author: Javier Arques
Version: 1.0
*/
@javierarques
javierarques / gist:9919188
Created April 1, 2014 17:42
Removes facebook avatar metas saved by wp fb autoconnect plugin when a Buddypress user upload a new avatar
/**
* Removes facebook avatar URL save in user metas by wp fb autoconnect plugin
* requires Buddypress & wp-fb-autoconnect
* @global type $bp
*/
function remove_facebook_avatar () {
global $bp;
delete_user_meta($bp->displayed_user->id, 'facebook_avatar_full');
delete_user_meta($bp->displayed_user->id, 'facebook_avatar_thumb');
}
@javierarques
javierarques / gist:9070480
Created February 18, 2014 12:58
Create multiple Buddypress profile fields. Crear varios campos de Buddypress con una query mysql, en este ejemplo creamos todos los países.
function bulk_insert_buddypress_fields ( $group_id, $parent_id, $type ) {
$fields =
"Afganistán
Albania
Alemania
Andorra
Angola
Anguilla
Antártida
Antigua y Barbuda
@javierarques
javierarques / gist:8577543
Created January 23, 2014 12:07
Woocommerce - Filter orders in wp-admin by products
/***********************************************************************************
* 2. FILTRO POR PRODUCTOS EN PEDIDOS
***********************************************************************************/
define('FILTRO_PRODUCT_NAME', 'filtro_producto');
define('ORDER_POST_TYPE', 'shop_order');
/**
* Añade la query de las sedes
* Hook 'pre_get_posts'
@javierarques
javierarques / gist:8304351
Created January 7, 2014 18:43
[WP] Create post with Contact Form 7 post data via wpcf7_before_send_mail hook
add_action('wpcf7_before_send_mail', 'cf7_create_post', 10, 1);
function cf7_create_post( $data ) {
extract($data->posted_data);
$post_id = wp_insert_post( array(
'post_status' => 'draft',
'post_title' => $nombre,
'post_content' => $consulta