Skip to content

Instantly share code, notes, and snippets.

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

Edir Pedro edirpedro

🏠
Working from home
View GitHub Profile
@edirpedro
edirpedro / form.php
Last active August 29, 2015 14:09
Execução de formulário simples com retorno usando a mesma página
<?php
// Executa o formulário quando submetido
if (!empty($_POST)) {
$nome = $_POST['nome'];
$mensagem = "Formulário processado $nome!";
}
@edirpedro
edirpedro / ci_session.php
Last active November 10, 2015 13:00
Loading CodeIgniter Session Externally
if(!session_id())
session_start();
if(isset($_COOKIE['ci_session'])) {
session_unset();
$session = file_get_contents("/var/tmp/ci_session" . $_COOKIE['ci_session']);
session_decode($session);
}
print_r($_SESSION);
@edirpedro
edirpedro / hasCSS.js
Created July 6, 2015 23:42
Check support for a CSS property
function hasCSS(name) {
// Checking an array
if (typeof name == 'object') {
for (var n in name) {
if (hasCSS(name[n]) === false)
return false;
}
return true;
}
@edirpedro
edirpedro / jquery.findfirst.js
Created July 15, 2015 15:22
Search for the first element found in the objects array passed
/*
* Function findFirst() will search for the first element found in the objects array passed
* $.findFirst('selector', [element, document]);
*/
$.extend({
findFirst: function(selector, objs) {
for (var i in objs) {
var elem = jQuery(selector, objs[i]);
if (elem.length) return elem;
}
@edirpedro
edirpedro / chapeu-eleitoral.html
Created July 23, 2015 00:33
Proposta de layout para a extensão Chapéu Eleitoral
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link href="jquery.qtip.css" rel="stylesheet">
<style>
.qtip-chapeu { max-width: 350px; font: 12px/18px Arial, sans-serif !important; }
.candidato-info { overflow: hidden; margin-bottom: 10px; }
.candidato-info img { float: left; max-width: 90px; max-height: 126px; margin-right: 20px; }
@edirpedro
edirpedro / wp_image_editor_method_exact.php
Last active August 29, 2015 14:26
Method "Exact" for WP Image Editor, will return the image with the exactly size requested, scaling it if necessary.
/*
* Method "exact" for WP Image Editor
*
* Usage: exact($image, array(200, 200, true)) using same "resize" arguments from WP Image Editor.
* https://codex.wordpress.org/Class_Reference/WP_Image_Editor
*
* @description: Return the exact size from an image, scaling it when necessary.
* @created: 31/07/15
* @param object $image - The WP Image Editor instance
* @param array $args - The same arguments from "resize" method
@edirpedro
edirpedro / wp_sanitize_file_name.php
Last active March 19, 2019 09:26
Translit file names to simple chars, this prevent WordPress to allow accents and special chars at file names that breaks in some server's configuration.
/*
* Translit file names to simple chars,
* this prevent accents and special chars at file names.
***********************************************************************/
function my_sanitize_file_name($filename) {
return remove_accents($filename);
}
add_filter('sanitize_file_name', 'my_sanitize_file_name');
/*
@edirpedro
edirpedro / typekit.editor.php
Created October 20, 2015 15:01 — forked from mikemanger/typekit.editor.php
Add a TypeKit font to the TinyMCE editor in WordPress.
add_filter( 'mce_external_plugins', 'my_theme_mce_external_plugins' );
function my_theme_mce_external_plugins( $plugin_array ) {
$plugin_array['typekit'] = get_template_directory_uri() . '/typekit.tinymce.js';
return $plugin_array;
}
@edirpedro
edirpedro / gravityforms-full-width.css
Created November 10, 2015 18:27
Gravity Forms Full Width
.gform_wrapper {
width: 100%;
max-width: 100%;
}
.gform_wrapper form {
width: 105%;
padding-left: 2.5%;
margin-left: -2.5%;
}
@edirpedro
edirpedro / wp_instagram_feed.php
Last active July 18, 2023 17:07
Function to get Instagram feed and cache it on WordPress
/*
* WP Instagram Feed
*
* To get a new Access Token, change the [], put it in the browser and it will return with your token in the next URL.
* https://instagram.com/oauth/authorize/?client_id=[CLIENT_ID]&redirect_uri=[REDIRECT_URL]&response_type=token
*********************************************************************/
function wp_instagram_feed($count = 20) {
$slug = "instagram_feed_self";
$access_token = '[ACCESS_TOKEN_HERE]';