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 / 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. '
@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 / 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 / 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 / .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 / 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 / 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 / Ignore .idea from git
Last active October 1, 2019 10:43
Ignore .idea folder from git in PHPStorm
1. Make PHPStorm ignore .idea folder
|- File > Settings > Version Control > Ignored Files > Add(+) > Ignored all files under > select directory .idea
2. Clean PhpStorm Git Cache
|- Open Terminal (Left+Down) #> "C:\Program Files (x86)\Git\cmd\git.exe" rm -f --cached .idea/*
or
|- Open Terminal (Left+Down) #> git rm -f --cached .idea/*
3. Reboot PhpStorm
\- Done!
@oropesa
oropesa / WP FTP SSH wp-config.php
Created December 15, 2014 14:29
Edit wp-config.php to update WP by FTP-SSH2
1. Install SSH2 and PHP mod, and restart Apache2
|- #> sudo apt-get install libssh2-1-dev libssh2-php
\- #> sudo service apache2 restart
2. Generate RSA keys, Create authorized_keys, and Update permissions
|- #> ssh-keygen
|- TIP: do not save them in your web directory
|- #> cd .ssh/
|- #> cp id_rsa.pub authorized_keys
|- #> cd ../
|- #> chmod 775 .ssh
@oropesa
oropesa / Add WP Users Table Register Sortable Column
Last active August 29, 2015 14:16
Add in Users Table from Wordpress Dashboard a new sortable column with user_registered datum (Register Date).
<?php
function alisios_add_user_column_registered( $columns ) {
$columns[ 'user_registered' ] = 'Register Date';
return $columns;
}
add_filter( 'manage_users_columns', 'alisios_add_user_column_registered' );
function alisios_add_user_sortable_column_registered( $columns ) {
$columns[ 'user_registered' ] = 'user_registered';
return $columns;