Skip to content

Instantly share code, notes, and snippets.

View raisiqueira's full-sized avatar
👽
learning something new!

Raí Siqueira raisiqueira

👽
learning something new!
View GitHub Profile

Finishing this guide you'll get:

  • A running WordPress installation
  • Nginx proxy with PHP and Fast CGI
  • MySQL server accessible with phpMyAdmin

Specification of latest running installation:

  • Date: 03.03.2014
<?php
//Rota de Paginaçnao
/**
* Rotina recebe o parametro $pagina para poder realizar a paginação
**/
$application->get('/minharota/:pagina', function ($pagina) use ($twig_engine) {
$registros_por_pagina=20;
$meusdados = Capsule::table('minhatabela')->skip($registros_por_pagina*$pagina)->take($registros_por_pagina)->get();
@raisiqueira
raisiqueira / cidades.route.php
Created April 13, 2015 12:41
Rota Cidades Ajax
/**
* Retorno Ajax para as cidades no formulário de cadastro
*/
$app->get('/cadastro/cidades/', function() use($app, $ajustes, $capsule){
//tipo de requisição
$req = $app->request();
$req->getContentType('application/xml;charset=utf-8');
// Pega o id do estado pela url
$estado = $app->request()->params('pesquisa');
@raisiqueira
raisiqueira / cidades.js
Created April 13, 2015 13:30
Javascript para retornar as cidades em ajax
$(function(){
$('#estados').change(function(){
if( $(this).val() ) {
$('#cidades').hide();
$('.carregando').show();
$.getJSON('{{site_url}}/cadastro/cidades?pesquisa=',{cod_estados: $(this).val(), ajax: 'true'}, function(j){
var options = '<option value=""></option>';
for (var i = 0; i < j.length; i++) {
options += '<option value="' + j[i].cod_cidades + '">' + j[i].nome + '</option>';
}
@raisiqueira
raisiqueira / default
Created April 29, 2015 12:31
Nginx Config para Wordpress Multisite
server {
##DM - uncomment following line for domain mapping
#listen 80 default_server;
server_name example.com *.example.com ;
##DM - uncomment following line for domain mapping
#server_name_in_redirect off;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
@raisiqueira
raisiqueira / time_ago.php
Created April 30, 2015 01:13
Função "time ago"
<?php
//http://codeforgeek.com/2014/10/time-ago-implementation-php/
function get_timeago( $ptime )
{
$estimate_time = time() - $ptime;
if( $estimate_time < 1 )
{
return 'less than 1 second ago';
}
@raisiqueira
raisiqueira / index.php
Created May 8, 2015 12:20
Hello World Slim Framework
<?php
//Faça o require do arquivo vendor.php do composer
//Depois de instanciado o arquivo vendor do composer, vamos instanciar o Slim
$app = new Slim\Slim(array(
'debug' => true,
//'view' => new Slim\Views\Twig(), //Aqui você trabalha com views personalizadas, no caso o twig.
'mode' => 'development',
));
@raisiqueira
raisiqueira / nginx.vhost
Last active September 16, 2015 11:56 — forked from vedovelli/nginx.vhost
server {
listen 80;
server_name CHANGEME.app;
root /var/www/vhosts/CHANGEME.app/public;
index index.html index.htm index.php;
charset utf-8;
location / {
<?php
add_filter( 'jetpack_get_available_modules', 'prefix_hide_jetpack_modules' );
/**
* Disable all non-whitelisted jetpack modules.
*
* As it's written, this will allow all of the currently available Jetpack
* modules to work display and be activated normally.
*
* If there's a module you'd like to disable, simply comment it out or remove it
* from the whitelist and it will no longer be available for activation.
<?php
//Muda a prioridade da metabox do YOAST SEO
function yoast_to_bottom() {
return 'low';
}
add_filter( 'wpseo_metabox_prio', 'yoast_to_bottom');