Skip to content

Instantly share code, notes, and snippets.

/* Force email lowercase on WordPress registration
------------------------------------------------------------------ */
function filter_pre_user_email( $raw_user_email ) {
$raw_user_email = strtolower($raw_user_email);
return $raw_user_email;
};
// add the filter
function agregar_cpts_en_loop($query) {
if ($query->is_feed() || $query->is_main_query() && $query->is_front_page()) {
$query->set('post_type', array('post', 'YOUR_POST_TYPE'));
}
}
add_action('pre_get_posts', 'agregar_cpts_en_loop');
function pw_send_subscription_cancelled_to_admin( $sub_id, $subscription ) {
$email_to = 'your@email.com';
$subject = 'Subscription Cancelled';
$message = 'Subscription cancelled for ' $subscription->customer->email;
EDD()->emails->send( $email_to, $subject, $message );
}
add_action( 'edd_subscription_cancelled', 'pw_send_subscription_cancelled_to_admin', 10, 2 );
function pw_send_subscription_failed_to_admin( $subscription ) {
$email_to = 'your@email.com';
add_filter('locale', 'jb_setLocale');
function jb_setLocale($locale) {
if ( is_admin() ) {
return 'en_US';
}
return $locale;
}
// Añadir valor en píxel conversión Facebook con WooCommerce
add_action( 'woocommerce_thankyou', 'jb_pixeltracking' );
function jb_pixeltracking( $order_id ) {
$order = new WC_Order( $order_id );
$order_total = $order->get_total();
?>
  <!-- Nuevo pixel de Facebook, acción conversión dinámica -->
<script>
fbq('track', 'Purchase', {value: '<?php echo $order_total ?>', currency: 'EUR'});
add_action( 'woocommerce_checkout_process', 'jb_minimum_order_amount' );
function jb_minimum_order_amount() {
global $woocommerce;
$minimum = 50;
if ( $woocommerce->cart->get_cart_total(); < $minimum ) {
$woocommerce->add_error( sprintf( 'Como mínimo necesitas comprar por valor de %s para procesar la compra.' , $minimum ) );
}
}
@boluda
boluda / gist:5c84ecdd4384281a6544
Created July 1, 2014 05:38
Register and enqueue Google Fonts (the right way)
/**
* Register and enqueue Google Fonts (the right way)
*/
function jb_google_fonts() {
// register styles
wp_register_style('googlefont-oswald', 'http://fonts.googleapis.com/css?family=Oswald:400,300,700', array(), false, 'all');
// enqueue styles
@boluda
boluda / gist:7271408
Created November 1, 2013 20:24
Negar acceso al backoffice de los suscriptores
// Negar acceso al backoffice de los suscriptores
function jbl_redirect_admin(){
if ( ! current_user_can( 'edit_posts' ) ){
wp_redirect( site_url() );
exit;
}
}
add_action( 'admin_init', 'jbl_redirect_admin' );
@boluda
boluda / Register Sidebar in Genesis
Last active December 25, 2015 19:49
Register Sidebar in Genesis
genesis_register_sidebar( array(
'id' => 'custom-sidebar',
'name' => __( 'Custom Sidebar', 'genesis' ),
'description' => __( 'My Custom Sidebar, aka Widget Area', 'childtheme' ),
) );