Skip to content

Instantly share code, notes, and snippets.

View pedrorvidal's full-sized avatar

Pedro Vidal pedrorvidal

View GitHub Profile
@pedrorvidal
pedrorvidal / EntityRepo.php
Created September 22, 2015 17:57
Get background funcionando
/**
*
* @return object
*/
public function getBackgroundHomeFunc()
{
return $this->getEntityManager()
->createQueryBuilder()
->select('b')
@pedrorvidal
pedrorvidal / NoticiaGaleria.php
Last active October 14, 2015 20:34
Erro no controller
<?php
namespace Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* NoticiaGaleria
*
* @ORM\Table(name="tb_noticia_galeria", indexes={@ORM\Index(name="IDX_3135593E478D78F9", columns={"id_galeria"}), @ORM\Index(name="IDX_3135593ED8407959", columns={"id_noticia"})})
@pedrorvidal
pedrorvidal / adapter.php
Created January 26, 2016 16:53
adapter.php
public function authenticate() {
//Dados de usuário que são necessários
$dadosUser['loginUser'] = $this->username;
$dadosUser['grupo'] = 1;
// $consult = $this->em2->getConnection()->executeQuery("SELECT TX_LOGIN_USUARIO, TX_NOME_USUARIO, TX_TELEFONE_USUARIO, TX_RAMAL_USUARIO, TX_EMAIL_USUARIO, TX_SENHA_USUARIO, TX_ESTADO_USUARIO, DT_INICIO_ESTADO_USUARIO, DT_MUDANCA_ESTADO_USUARIO, "
// . "TX_USUARIO_BLOQUEADO, DT_ULTIMO_ACESSO, TX_USUARIO_CONECTADO, QT_TENTATIVA_CONEXAO, DT_EXPIRACAO_SENHA, TX_SIGLA_SETOR, TX_CLASSE_USUARIO, TX_CNPJ_EMPRESA "
// . "FROM USUARIO " . "WHERE TX_LOGIN_USUARIO = '{$this->username}' AND TX_SENHA_USUARIO = '".sha1($this->password)."' ");
//
// analsl
@pedrorvidal
pedrorvidal / container.php
Created January 28, 2016 11:24
Classe container
<?php
namespace Container;
use Zend\Session\SessionManager;
use Pimple;
use Zend\Log\Logger;
use Zend\Log\Writer\Stream;
/**
@pedrorvidal
pedrorvidal / Gruntfile.js
Created July 6, 2016 19:32 — forked from jshawl/Gruntfile.js
Grunt + Sass + Autoprefixer
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist: {
options:{
style:'compressed'
},
files: {
'css/style.css' : 'scss/style.scss'
@pedrorvidal
pedrorvidal / site.local.conf
Last active August 1, 2020 13:30
Virtual Hosts Ubuntu + Apache2
# sudo vim /etc/apache2/sites-available/exemplo.local.com.conf
<VirtualHost *:80>
ServerName exemplo.local.com
DocumentRoot /var/www/html/exemplo
<Directory /var/www/html/exemplo>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<?php
// in function .php write following code
//Here we gather the files which sent by the HTML forms. and send it to //another function called kv_handle_attachement(). This is a simple function //this will help you to store the files to your wp uploads directory. Add //the following code into your Theme “ functions.php”
//img upload//
function kv_handle_attachment($file_handler,$post_id,$set_thu=false) {
// check to make sure its a successful upload
if ($_FILES[$file_handler][‘error’] !== UPLOAD_ERR_OK) __return_false();
require_once(ABSPATH . “wp-admin” . ‘/includes/image.php’);
require_once(ABSPATH . “wp-admin” . ‘/includes/file.php’);
@pedrorvidal
pedrorvidal / functions.php
Created December 21, 2016 12:45
Upload arquivos acentuados WordPress
<?php
// https://wordpress.org/support/topic/uploaded-image-with-accents-in-name-image-dont-show-in-safari-6
function sanitize_filename_on_upload($filename) {
$ext = end(explode('.', $filename));
// Replace all weird characters
$sanitized = preg_replace('/[^a-zA-Z0-9-_.]/', '', substr($filename, 0, -(strlen($ext)+1)));
// Replace dots inside filename
$sanitized = str_replace('.', '-', $sanitized);
return strtolower($sanitized.'.'.$ext);
}
@pedrorvidal
pedrorvidal / gist:bb97b3a9711c54b3aca411380028ce86
Created January 30, 2017 19:50 — forked from danielbachhuber/gist:7126249
Include posts from authors in the search results where either their display name or user login matches the query string
<?php
/**
* Include posts from authors in the search results where
* either their display name or user login matches the query string
*
* @author danielbachhuber
*/
add_filter( 'posts_search', 'db_filter_authors_search' );
function db_filter_authors_search( $posts_search ) {