Skip to content

Instantly share code, notes, and snippets.

View asllanmaciel's full-sized avatar
🎯
Focusing

Asllan Maciel asllanmaciel

🎯
Focusing
View GitHub Profile
<?php
function cpt_shortcode(){
$args = array(
'post_type' => 'at_biz_dir', // Custom Post Type
'posts_per_page' => -1,
//'orderby' => 'date', // we will sort posts by date
//'order' => $_POST['date'] // ASC or DESC
);
//Start variable to the content
@asllanmaciel
asllanmaciel / estados.php
Created August 11, 2021 17:02 — forked from ricardobarantini/estados.php
Array com nome e siglas de estados Brasileiros para select do Codeigniter
$estadosBrasileiros = array(
'AC'=>'Acre',
'AL'=>'Alagoas',
'AP'=>'Amapá',
'AM'=>'Amazonas',
'BA'=>'Bahia',
'CE'=>'Ceará',
'DF'=>'Distrito Federal',
'ES'=>'Espírito Santo',
'GO'=>'Goiás',
@asllanmaciel
asllanmaciel / gist:69e2a3053704dde595656c72b512dc14
Created August 11, 2021 23:57 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@asllanmaciel
asllanmaciel / check-all-other.js
Created August 13, 2021 21:50
Check All and Other with jQuery
$(document).ready(function() {
//See working in https://jsfiddle.net/asllanmaciel/qw5zj7an/4/
//check all checkboxes (array) except element ".outras"
$('input.all[name=tratamento_doencas\\[\\]]').click(function() {
$('input[name=tratamento_doencas\\[\\]]').not(this).not('.outras').prop('checked', this.checked);
});
//hide container
@asllanmaciel
asllanmaciel / contagem-notas.php
Created August 14, 2021 17:11
Script para contagem de notas
<?php
if($_POST){
$arr = (array) $_POST['sintomas'];
$count = 0;
foreach($arr as $key => $value){
//echo $key . '<>' . $value . '<br>';
$count = $count + explode('|',$value)[0];
}
echo 'TOTAL:'.$count . '<br>';
@asllanmaciel
asllanmaciel / slugify-01.php
Created August 16, 2021 19:44
slugifing-wp.php
<?php
//taken from wordpress
function utf8_uri_encode( $utf8_string, $length = 0 ) {
$unicode = '';
$values = array();
$num_octets = 1;
$unicode_length = 0;
$string_length = strlen( $utf8_string );
for ($i = 0; $i < $string_length; $i++ ) {
<?php
function slugify($text, string $divider = '-')
{
// replace non letter or digits by divider
$text = preg_replace('~[^\pL\d]+~u', $divider, $text);
// transliterate
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
// remove unwanted characters
<?php
function slugify($string) {
$table = array(
'Š'=>'S', 'š'=>'s', 'Đ'=>'Dj', 'đ'=>'dj', 'Ž'=>'Z', 'ž'=>'z', 'Č'=>'C', 'č'=>'c', 'Ć'=>'C', 'ć'=>'c',
'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E',
'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O',
'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U', 'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss',
'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'ç'=>'c', 'è'=>'e', 'é'=>'e',
'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o',
@asllanmaciel
asllanmaciel / cf7-insert-ext-db.php
Created August 18, 2021 00:31
Insert Contact Form 7 Submissions (WordPress) in External DB with PHP/MySQL
<?php
//Use in theme functions.php
function save_db($cf7){
$submission = WPCF7_Submission::get_instance();
if($submission){
$posted_data = $submission->get_posted_data();
}
@asllanmaciel
asllanmaciel / datetime-decrease-15d.php
Created August 24, 2021 14:05
Decreasing 15d of current date
<?php
$atual = date("Y-m-d");
$atual_dt = new DateTime($atual);
$atual_dt_sub = $atual_dt->sub(new DateInterval('P15D'));
echo $atual_dt_sub->format('Y-m-d');