Skip to content

Instantly share code, notes, and snippets.

View juanjosezg's full-sized avatar
💻

Juan José Zermeño juanjosezg

💻
View GitHub Profile
@juanjosezg
juanjosezg / functions.php
Created June 11, 2022 02:09
Add Wrapper to Youtube Embed
add_filter('oembed_dataparse','oembed_youtube_add_wrapper',10,3);
function oembed_youtube_add_wrapper($return, $data, $url) {
if ($data->provider_name == 'YouTube') {
return "<div class='youtube-wrapper'>{$return}</div>";
} else {
return $return;
}
}
@juanjosezg
juanjosezg / functions.php
Created November 17, 2020 19:20
Add Country Prefix to Woocomerce Chekout
<?php
add_action( 'wp_footer', 'scripts_for_adding_country_prefix_on_billing_phone' );
function scripts_for_adding_country_prefix_on_billing_phone(){
?>
<script type="text/javascript">
( function( $ ) {
$( document.body ).on( 'updated_checkout', function(data) {
var ajax_url = "<?php echo admin_url('admin-ajax.php'); ?>",
country_code = $('#billing_country').val();
var ajax_data = {
@juanjosezg
juanjosezg / database-backup.php
Created July 17, 2020 00:19
Backup Database PHP
<?php
$database_name = '';
$username = '';
$password = '';
$host = '';
// Get connection object and set the charset
$conn = mysqli_connect($host, $username, $password, $database_name);
$conn->set_charset("utf8");
@juanjosezg
juanjosezg / wp-download.sh
Created November 8, 2019 17:30
Download Latest Worpress Version
#!/bin/bash
#
# Download the latest Wordpress version
#
wget http://wordpress.org/latest.tar.gz
tar xfz latest.tar.gz
mv wordpress/* ./
rmdir ./wordpress/
rm -f latest.tar.gz
@juanjosezg
juanjosezg / wp-dreamhost.sh
Last active November 8, 2019 17:04
Wordpress Permissions Dreamhost
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro (https://gist.github.com/macbleser/9136424)
#
WP_ROOT=${1:-.} # <-- wordpress root directory, current directory by default
[ -e "$WP_ROOT/wp-config.php" ] || { echo "Usage: $0 /path/to/wordpress"; exit; } # <-- detect that the directory is a wordpress root
@juanjosezg
juanjosezg / wordpress-perm.sh
Created November 8, 2019 16:50
WordPress Permissions Configuration Script
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro (https://gist.github.com/macbleser/9136424)
#
WP_ROOT=${1:-.} # <-- wordpress root directory, current directory by default
[ -e "$WP_ROOT/wp-config.php" ] || { echo "Usage: $0 /path/to/wordpress"; exit; } # <-- detect that the directory is a wordpress root
WP_OWNER=$(id -u $(logname)) # <-- wordpress owner (This assumes the wordpress owner is the logged in user)
@juanjosezg
juanjosezg / functions.php
Last active March 21, 2019 17:35
Hide Wordpress Notificarions
<?php
/* Hide Wordpress Notifications */
function remove_core_updates(){
global $wp_version;return(object) array('last_checked'=> time(),'version_checked'=> $wp_version,);
}
add_filter('pre_site_transient_update_core','remove_core_updates'); // For WordPress
add_filter('pre_site_transient_update_plugins','remove_core_updates'); // For all plugins
add_filter('pre_site_transient_update_themes','remove_core_updates'); // For all themes
@juanjosezg
juanjosezg / multipleEventsListeners.js
Created February 22, 2019 18:15 — forked from juanbrujo/multipleEventsListeners.js
Add the capability to attach multiple events to an element, just like jQuery does
/**
* multipleEventsListeners.js
* Add the capability to attach multiple events to an element, just like jQuery does
* https://gist.github.com/juanbrujo/a1f77db1e6f7cb17b42b
*/
function multipleEventsListeners(elem, events, func) {
var event = events.split(' ');
for (var i = 0; i < event.length; i++) {
elem.addEventListener(event[i], func, false);
function struuid($entropy)
{
$s=uniqid("",$entropy);
$num= hexdec(str_replace(".","",(string)$s));
$index = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
$base= strlen($index);
$out = '';
for($t = floor(log10($num) / log10($base)); $t >= 0; $t--) {
$a = floor($num / pow($base,$t));
### Keybase proof
I hereby claim:
* I am juanjosezg on github.
* I am juanjosezg (https://keybase.io/juanjosezg) on keybase.
* I have a public key ASBib1CwRFgUl5PQDafdkTYsZoKTTG1wh1_TGzyn6TqkLwo
To claim this, I am signing this object: