Skip to content

Instantly share code, notes, and snippets.

View javierarques's full-sized avatar

Javier javierarques

View GitHub Profile
@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: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 / 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 / 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 / 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 / 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 / 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 / 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 / en_US.po
Created June 26, 2014 16:11
Wordpress. Poedit file to translate a theme.
msgid ""
msgstr ""
"Project-Id-Version: THEME\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-06-26 17:38+0100\n"
"PO-Revision-Date: \n"
"Language-Team: TEAM <my@email.com>\n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@javierarques
javierarques / admin.php
Last active August 29, 2015 14:03
CUSTOM ADMIN FILTER: Add taxonomy filter to wp-admin posts listing
/**************************************************************************************
* CUSTOM ADMIN FILTER
* Add taxonomy filter to wp-admin posts listing
**************************************************************************************/
add_action( 'restrict_manage_posts', 'my_restrict_manage_posts' );
function my_restrict_manage_posts() {
global $typenow;