Skip to content

Instantly share code, notes, and snippets.

@pedroelsner
pedroelsner / gist:5897ff36f1296b90af2f
Last active August 29, 2015 14:05
Edson - Load page ID
<?
/**
* Carrega a API do WordPress
*/
define('WP_USE_THEMES', false); // Não utiliza nenhum tema
require('./wordpress/wp-load.php');
$query = new WP_Query( 'page_id=7' );
if ( $the_query->have_posts() ) {
@pedroelsner
pedroelsner / gist:90af693bd42c98001428
Created September 9, 2014 19:39
Script Qlikview para Alexandre Gabriel
Original:
LOAD * INLINE [
Objeto, ID
Ref1, 13
Ref1, 16
Ref1, 19
Ref1, 32
];
@pedroelsner
pedroelsner / gist:4d5e466f2fe227250b59
Last active August 29, 2015 14:06
Felipe - Filter Results
<?
//$this->Importacao->recursive = -1
//$this->Filter->setPaginate('contain', array('Importacaodado'));
// ou
$this->Importacao->recursive = 1;
$this->Filter->addFilters(array('filter1' => array( ect.....)));
$this->Filter->setPaginate('order', array('Importacao.id' => 'desc'));
@pedroelsner
pedroelsner / menu-nav.php
Created September 13, 2011 02:13
Exemplo de Menu com o Helper ACL_Html
<ul id="main-nav">
<?php
/**
* CADASTROS BÁSICOS
*/
/**
* Lista das URLs para verificar permissão
*/
@pedroelsner
pedroelsner / user.php
Created October 12, 2011 14:35
Filter Results forçando parametro no 'conditions' do Paginate
<?php
// Filter Results
$this->FilterResults->addFilters(
array(
'filter1' => array(
'User.name' => array(
'operator' => 'LIKE',
'beforeValue' => '%',
'afterValue' => '%'
),
@pedroelsner
pedroelsner / gist:2778226
Created May 23, 2012 22:27
Html Injection
<?php $procurar = htmlspecialchars($_GET['procurar']); ?>
@pedroelsner
pedroelsner / gist:2778297
Created May 23, 2012 22:43
Utilização da clase Sanitize
<?php
// Importa a classe necessária
require_once('sanitize.php');
// Filtra HTML e SQL Injection em todos os campos
$_GET = Sanitize::filter($_GET);
$_POST = Sanitize::filter($_POST);
// Somente HTML Injection
$_POST = Sanitize::filter($_POST, array('html'));
@pedroelsner
pedroelsner / gist:2778319
Created May 23, 2012 22:48
#2 - Plugin WordPress - Hello Word
<?php
/**
* Função que adiciona o texto "Hello World!" ao conteudo do post
*
* @param string $content
* @return string
*/
function hello_world_content_filter ( $content ) {
$content .= '<strong>Hello World!</strong>';
return $content;
@pedroelsner
pedroelsner / gist:2778332
Created May 23, 2012 22:52
#4 - Plugin WordPress - Hello Word
<?php
// Adiciona/Atualiza valor da variável
update_post_meta( $post_id, $meta_key, $meta_value, $prev_value );
// Retorna o valor da variável
get_post_meta( $post_id, $meta_key, $single )
// Apaga a variável
delete_post_meta( $post_id, $meta_key, $meta_value );
?>
@pedroelsner
pedroelsner / gist:2778327
Created May 23, 2012 22:50
#3 - Plugin WordPress - Hello Word
<?php
/**
* Função que exibe o conteúdo do quadro
*/
function hello_world_meta_box() {
global $post;
echo '<input id="hello_world_nonce" name="hello_world_nonce" type="hidden" value="' . wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
echo '<input id="hello_world_opt_mostrar_mensagem" name="hello_world_opt_mostrar_mensagem" type="checkbox" />';