Skip to content

Instantly share code, notes, and snippets.

View alandbh's full-sized avatar

Alan Vasconcelos alandbh

View GitHub Profile
@alandbh
alandbh / docker_wordpress.md
Created June 25, 2020 17:03 — forked from bradtraversy/docker_wordpress.md
Docker Compose FIle For Wordpress, MySQL & phpmyadmin

Wordpress & Docker

This file will setup Wordpress, MySQL & PHPMyAdmin with a single command. Add the code below to a file called "docker-compose.yaml" and run the command

$ docker-compose up -d

# To Tear Down
$ docker-compose down --volumes
@alandbh
alandbh / mysql-docker.sh
Created April 24, 2020 00:02 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@alandbh
alandbh / date_i18n
Created June 21, 2019 04:51
Wordpress built-in function to display international dates properly. Retrieve the date in localized format, based on timestamp.
$_evento = get_proximos_eventos(1);
$evento = $_evento[0];
$unixtimestamp_inicio = strtotime($evento['data_inicio']);
echo date_i18n('M', $unixtimestamp_inicio); // Abril
// Depending on your blog settings you will see the date displayed in your local format, for example: 15. november 1976.
echo date_i18n( get_option( 'date_format' ), strtotime( '11/15-1976' ) );
@alandbh
alandbh / fontface-sass-mixin
Last active April 5, 2019 21:57
Sass mixing for importing web-fonts
// =============================================================================
// String Replace
// =============================================================================
@function str-replace($string, $search, $replace: '') {
$index: str-index($string, $search);
@if $index {
@return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
}
@alandbh
alandbh / _spacing-helpers.scss
Created March 22, 2019 22:52 — forked from jacurtis/_spacing-helpers.scss
SASS Margin and Padding Helpers Loop. Generates .m-t-10 type helper classes.
/*
This .scss loop will create "margin helpers" and "padding helpers" for use in your web projects.
It will generate several classes such as:
.m-r-10 which gives margin-right 10 pixels.
.m-r-15 gives MARGIN to the RIGHT 15 pixels.
.m-t-15 gives MARGIN to the TOP 15 pixels and so on.
.p-b-5 gives PADDING to the BOTTOM of 5 pixels
.p-l-40 gives PADDING to the LEFT of 40 pixels
@alandbh
alandbh / Message.jsx
Last active September 17, 2017 03:58
React/Material UI - Inplace Message component
/* ----------------
This is an inplace message component (not dialog, toaster, snackbar or modal)
It must be used with Material UI
Usage:
<Message
type="success"
title="Congratulations!"
content="Your documents fulfill all the requirements. We'll contact you soon." />
@alandbh
alandbh / gallery_wp_2.0.php
Last active September 17, 2017 03:30
Galeria wp 2.0
@alandbh
alandbh / shortcode_youtube.php
Last active September 17, 2017 03:31
shortcode for embeding youtube videos
/*
---------- Shortcode for Youtube videos
Alan
*/
class short_youtube {
function shortcode($atts, $content = null)
{
extract(shortcode_atts(array(
'alinhamento' => '',
@alandbh
alandbh / activates-menu-item.php
Last active September 17, 2017 03:33
This code sets de current menu item for single CPT
/* ----------------
It applies the class "active" or "current-menu-item" on menu item of a parent page
Alan
----------------- */
add_action('nav_menu_css_class', 'add_current_nav_class', 10, 2 );
function add_current_nav_class($classes, $item) {
@alandbh
alandbh / get_users_loop.php
Created April 30, 2017 14:13
A complete query go get all users in Wordpress loop with custom fields and date/time.// Uma query completa para pegar todos os usuários cadastrados e montar um loop com data e hora.
<?php
$args = array(
'blog_id' => $GLOBALS['blog_id'],
'role' => 'author',
'role__in' => array(),
'role__not_in' => array(),
'meta_key' => '',
'meta_value' => '',
'meta_compare' => '',
'meta_query' => array(),