Skip to content

Instantly share code, notes, and snippets.

View oropesa's full-sized avatar
🙂
I'm chachon

Oropesa oropesa

🙂
I'm chachon
View GitHub Profile
@oropesa
oropesa / core.less
Created November 25, 2014 13:49
Bootstrap Screen. Add size 'Extra Large'
/**
* BOOTSTRAP: SIZE EXTRA LARGE
*/
@screen-xl-min: 1480px;
@screen-lg-max: (@screen-xl-min - 1);
@container-extra-large-desktop: ((1420px + @grid-gutter-width));
@container-xl: @container-extra-large-desktop;
@modal-xl: 1100px;
@oropesa
oropesa / isset_get()
Created October 4, 2014 20:33
Check if the key of the array is valid and return it.
<?php
function isset_get( $array, $key, $default = null ) {
return isset( $array[ $key ] ) ? $array[ $key ] : $default;
}
/*
* In Wordpress, the most common PHP warning is when it uses an array index without check if that index is valid.
* So, you have to ask if the array index is valid:
* if( isset( $array['index'] ) )
* And then you can use it:
@oropesa
oropesa / .htaccess: url without www
Created September 23, 2014 14:00
redirect .htaccess without www
# BEGIN Oropesa
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.oropensando.com$ [NC]
RewriteRule ^(.*)$ http://oropensando.com/$1 [L,R=301]
</IfModule>
# END Oropesa
@oropesa
oropesa / Easy Array Manage
Last active August 29, 2015 14:06
Add and remove elements from an array. It uses the function string2array()
<?php
/**
* Use:
* $array = ('Hi', 'World')
* $array = manageArray('Foo, Bar Foobar', 'World');
* // output:
* // $array = ('Hi', 'Foo', 'Bar', 'Foobar')
*/
function easyArrayManage ($array, $addElements = '', $removeElements = '') {
@oropesa
oropesa / Cast hex to rgba Color
Last active August 29, 2015 14:06
Cast Hexadecimal Color to RGBA Color.
<?php
function hex2rgba($hex, $a = '1') {
$hex = str_replace('#', '', $hex);
if(strlen($hex) === 3) {
$r = hexdec( substr($hex,0,1) . substr($hex,0,1) );
$g = hexdec( substr($hex,1,1) . substr($hex,1,1) );
$b = hexdec( substr($hex,2,1) . substr($hex,2,1) );
} else {
$r = hexdec( substr($hex,0,2) );
@oropesa
oropesa / Cast String to Array (Wordpress)
Created August 30, 2014 15:47
Cast string to array (obviuosly), but it has implemented the Wordpress escaping HTML attributes too
<?php
/**
* Cast string to array. The separator is space ' ' or comma ','.
* @param $string
* @return array
*/
function string2array($string) {
$array = array();
if( is_string($string) )
@oropesa
oropesa / JS Cookies Managing (Wordpress, jQuery & Bootstrap)
Last active August 29, 2015 14:05
Wordpress Cookies Managing. Is not all the code, but It's the first template.
(function(){
var //cookie
, $btnCookie = $('#btn-acceptCookies')
, $divCookie = $('div.cookiesAlert')
, theCookieKey = 'THE_SITE_NAME_cookie_policy'
, theCookieVal = 'accepted'
, theCookieDays = 15
//cookie erasing
, $btnDeleteCookies = $('#btn-deleteAllCookies')
, cookieDeleteText = 'Our cookies have been removed from your device successfully. '