Skip to content

Instantly share code, notes, and snippets.

View wilnaweb's full-sized avatar

Wilson Cavalcante wilnaweb

View GitHub Profile
@wilnaweb
wilnaweb / html5pattern.txt
Last active July 18, 2018 21:45
Pattern HTML5 para CPF e CNPJ
CPF: "\d{3}.\d{3}.\d{3}-\d{2}"
CNPJ: "\d{2}.\d{3}.\d{3}\/\d{4}-\d{2}"
Telefone: "\([0-9]{2}\)[\s][0-9]{4}-[0-9]{4}"
Celular: "\([0-9]{2}\) [0-9]{4,6}-[0-9]{3,4}$"
Test:
CPF: http://bit.ly/2h7DnvF
CNPJ: http://bit.ly/2jv9xlU
Telefone: https://bit.ly/2LtZSoU
Celular: https://bit.ly/2mtjnDq
@wilnaweb
wilnaweb / wordpress.get.menu.itens.php
Created May 10, 2018 13:17
Função Personalizada de Menu Wordpress (Wordpress Custom Generator Menu )
############## functions.php
/**
* Register Navs & Menus
*/
function gd_register_menus(){
register_nav_menus( array(
'nav_top_menu' => 'Itens do menu na barra superior de navegação',
) );
}
add_action( 'init', 'gd_register_menus' );
@wilnaweb
wilnaweb / restore-utf8.sql
Created July 3, 2018 15:18
Mysql Import Com Utf8 (Restore Database)
mysql -uuser -ppassword --default-character-set=utf8 dbname < outputfille
@wilnaweb
wilnaweb / update-wordpress-url.sql
Created July 3, 2018 15:19
Update URL de Site Wordpress Direto no Banco de Dados
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
@wilnaweb
wilnaweb / vhosts.conf
Created July 3, 2018 15:20
Apache New Vhosts (Ambiente de Homologação e Testes)
## LINUX APACHE2
<VirtualHost *:80>
DocumentRoot /var/www/site.host.gd/public_html
ServerName site.host.gd
ErrorLog /var/www/site.host.gd/error.log
CustomLog /var/www/site.host.gd/access.log combined
ServerAlias www.site.host.gd
<Directory "/var/www/site.host.gd/public_html">
allow from all
AllowOverride All
@wilnaweb
wilnaweb / .htaccess
Last active January 12, 2022 18:29
Secure .htaccess Wordpress
# Set Header
<IfModule mod_headers.c>
Header set X-XSS-Protection "1; mode=block"
Header always append X-Frame-Options SAMEORIGIN
Header set X-Content-Type-Options nosniff
</IfModule>
@wilnaweb
wilnaweb / wp-admin.htaccess
Created September 10, 2018 22:54
Secure .htaccess wp-admin folder
# secure .htaccess file
<Files .htaccess>
Order allow,deny
Deny from all
</Files>
# Exclude the file upload and WP CRON scripts from authentication
<FilesMatch "(async-upload\.php|wp-cron\.php|xmlrpc\.php)$">
Satisfy Any
@wilnaweb
wilnaweb / array_months.php
Last active September 11, 2018 15:14
[PHP] Arrays Com Nome dos Meses
$months = array(
'pt-br' => array(
'1' => 'Janeiro',
'2' => 'Fevereiro',
'3' => 'Março',
'4' => 'Abril',
'5' => 'Maio',
'6' => 'Junho',
'7' => 'Julho',
'8' => 'Agosto',
@wilnaweb
wilnaweb / get_youtube_id.php
Created September 12, 2018 20:25
Get Youtube Video ID By URL
function _get_youtube_id($url)
{
$video_id = false;
$url = parse_url($url);
if (strcasecmp($url['host'], 'youtu.be') === 0)
{
#### (dontcare)://youtu.be/<video id>
$video_id = substr($url['path'], 1);
}
elseif (strcasecmp($url['host'], 'www.youtube.com') === 0)
@wilnaweb
wilnaweb / get_permalink_from_related_content_translated
Last active January 13, 2024 03:52
Function to get the translation link of related Wordpress content with WPML