Skip to content

Instantly share code, notes, and snippets.

View angelorocha's full-sized avatar
🏠
Working from home

Angelo Rocha angelorocha

🏠
Working from home
View GitHub Profile
@angelorocha
angelorocha / estados-cidades.json
Created July 6, 2023 17:20 — forked from letanure/estados-cidades.json
JSON estados cidades do brasil, dividido por estados. segunda lista atualizada em 2020, dados do IBGE
{
"estados": [
{
"sigla": "AC",
"nome": "Acre",
"cidades": [
"Acrelândia",
"Assis Brasil",
"Brasiléia",
"Bujari",
@angelorocha
angelorocha / install.md
Created April 18, 2023 15:10
Install php gd on centos 7 with php 8.1.10
@angelorocha
angelorocha / brazilian_holidays.php
Last active March 28, 2023 14:43
Brazilian holidays wordpress php class
<?php
/**
* Based on
* https://www.php.net/manual/pt_BR/function.easter-date.php#96686
*/
class BrazilHolidays {
/**
@angelorocha
angelorocha / array_to_table.php
Last active December 28, 2022 15:02
Multidimensional arrays to html table
<?php
$arr = [
'key_1' => [
'key_1_val_1',
'key_1_val_2',
'key_1_val_3',
'key_1_val_4',
],
'key_2' => [
'key_2_val_1',
@angelorocha
angelorocha / WPSSDummy.php
Last active December 20, 2021 13:24
Generate WordPress dummy posts with content and post thumbnail
<?php
/**
* Class WPSSDummy
*
* Generate dummy posts, see parameters of loripsum api:
*
* (integer) - The number of paragraphs to generate.
* short, medium, long, verylong - The average length of a paragraph.
* decorate - Add bold, italic and marked text.
@angelorocha
angelorocha / WPSSCtp.php
Last active October 22, 2021 20:13
WordPress class to generate post types
<?php
/**
* Class WPSSCpt
* Generate custom post types
*/
class WPSSCpt {
/**
* Class instance
@angelorocha
angelorocha / redux_sample.php
Created August 24, 2021 12:57
Problem with assets dir
<?php
if( !class_exists('Redux') ) {
return;
}
$opt_name = 'wpss_option';
$theme = wp_get_theme();
@angelorocha
angelorocha / wpss_get_remote_image.php
Created August 2, 2021 02:58
Get remote images and save as WordPress attachment
<?php
/**
* @author Angelo Rocha
* @copyleft 2021
* @license GNU GPL 3 (https://www.gnu.org/licenses/gpl-3.0.html)
*
* @param string $image Set url to get image
*
*/
@angelorocha
angelorocha / csv_to_array.php
Created July 5, 2021 16:53
Convert CSV file in array
<?php
/**
* Convert CSV file in Array
*
* @param string $file_csv CSV file path
*
* @return array|string
*/
function csv_to_array(string $file_csv){
if(!file_exists($file_csv)):
@angelorocha
angelorocha / custom-array-multisort.php
Created June 25, 2021 19:12
Order multidimensional array by key
<?php
/**
* Order array by key
* @param $array
* @param $array_key
* @param string $order
*
* @return bool
*/