Skip to content

Instantly share code, notes, and snippets.

@miguelpeixe
miguelpeixe / functions.php
Last active December 14, 2015 03:29
BAIXOCENTRO - Código no functions.php para armazenar query retornada pelo formulário e associar demanda à voluntário cadastrado
<?php
function baixocentro_save_demanda() {
global $cfs;
if(isset($_REQUEST['save_demanda'])) {
$post_id = $_REQUEST['project_id'];
$tipo_demanda = $_REQUEST['tipo_demanda'] == 'producao' ? 'demandas_producao' : 'demandas_equipamento';
$nome = $_REQUEST['nome'];
if(get_post($post_id)) {
$demandas = $cfs->get($tipo_demanda, $post_id);
@miguelpeixe
miguelpeixe / single.php
Created February 24, 2013 00:03
BAIXOCENTRO - Frontend para exibir lista de demandas, seus respectivos voluntários ou link para cadastro
<?php if(current_user_can('edit_posts')) : // bloqueado para usuário comum, temporariamente ?>
<h2>Este projeto precisa da sua ajuda!</h2>
<?php
global $cfs;
$demandas_producao = $cfs->get('demandas_producao');
if($demandas_producao) {
echo '<h3>Demandas de produção</h3>';
foreach($demandas_producao as $demanda) {
$url = 'http://festival.baixocentro.org/rede/?';
$url .= 'project_id=' . $post->ID;
@miguelpeixe
miguelpeixe / functions.php
Last active December 18, 2015 08:09
WordPress Advanced Search Example
<?php
function humus_advSearch_query($query) {
if(is_search() && $_REQUEST['tags']) {
$tax_query = array(
'taxonomy' => 'post_tag',
'terms' => $_REQUEST['tags'],
'field' => 'slug'
);
@miguelpeixe
miguelpeixe / map.geojson
Created August 28, 2013 20:19
via:geojson.io
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@miguelpeixe
miguelpeixe / infoamazonia.geojson
Created September 8, 2013 21:21
infoamazonia.geojson
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@miguelpeixe
miguelpeixe / qtranslate-nav.php
Created September 12, 2013 19:36
Programatic qTranslate nav menu
<?php if(function_exists('qtrans_getLanguage')) : ?>
<nav id="langnav">
<ul>
<?php
global $q_config;
if(is_404()) $url = get_option('home'); else $url = '';
$current = qtrans_getLanguage();
foreach($q_config['enabled_languages'] as $language) {
$attrs = '';
if($language == $current)
@miguelpeixe
miguelpeixe / functions.php
Last active December 23, 2015 13:39
JEO - Manipulação de marcador no evento de filtro do range slider. Exemplo com contagem de metadado nas propriedades do GeoJSON
<?php
// Javascript utilizado para realizar a contagem total
function jeo_child_scripts() {
wp_enqueue_script('test-range', get_stylesheet_directory_uri() . '/js/test-range.js', array('jquery', 'jeo.markers'));
}
add_action('jeo_markers_enqueue_scripts', 'jeo_child_scripts');
/* Inserção do dado que queremos na lista de propriedades GeoJSON
* No caso a função pega o metadado "valor_numero" e insere no GeoJSON como "custom_value"
@miguelpeixe
miguelpeixe / functions.php
Created October 9, 2013 18:06
Replace artist permalink to single artwork
<?php
function bhasia_artist_permalink($url, $post) {
if(get_post_type($post->ID) == 'artist') {
$ids = get_post_meta($post_id, '_artworks');
if($ids) {
$url = get_permalink(array_shift($ids));
}
}
@miguelpeixe
miguelpeixe / gist:7436559
Created November 12, 2013 18:52
Fix qTranslate javascript behaviour on Advanced Custom Fields

On the file qtranslate_javascript.php replace the line:

qtrans_save(switchEditors.pre_wpautop(o.content));

with:

@miguelpeixe
miguelpeixe / test.csv
Created November 28, 2013 20:00
Test
MMSI LAT LON SPEED COURSE STATUS TIMESTAMP
210138000 -12.493310 130.875500 0 220 3 2013-11-20T16:09:00
538003142 10.760050 106.795000 0 331 0 2013-11-20T16:10:00
566946000 1.276475 103.776200 4 180 0 2013-11-20T16:12:00
525007025 1.156115 103.716700 29 287 15 2013-11-20T16:06:00
563010630 1.208955 103.670200 157 290 0 2013-11-20T16:11:00
229584000 1.112355 103.513400 132 121 0 2013-11-20T16:09:00
325580000 1.307875 103.652700 0 20 8 2013-11-20T16:09:00
312825000 1.260572 103.692700 7 27 99 2013-11-20T16:09:00
413900365 0.058420 113.881500 58 177 99 2013-11-20T16:10:00