Skip to content

Instantly share code, notes, and snippets.

@igmoweb
igmoweb / ltu.php
Last active July 6, 2016 17:26
Adds a link at the end of all emails with a link to unsubscribe page
<?php
add_filter( 'wp_mail', 'ltu_add_unsubscribe_links' );
function ltu_add_unsubscribe_links( $args ) {
if ( ! class_exists( 'IW_LTU' ) ) {
// Let Them Unsubscribe is not active
return $args;
}
$email = $args['to'];
@igmoweb
igmoweb / appointments.php
Last active July 6, 2016 12:30
Overwrites GCal events title and description
<?php
add_filter( 'appointments_gcal_update_event', 'appointments_hooks_gcal_update_event', 10, 2 );
function appointments_hooks_gcal_update_event( $event, $appointment ) {
$appointments = appointments();
$gcal_api = $appointments->get_gcal_api();
$event = $gcal_api->appointment_to_gcal_event( $appointment->ID );
return $event;
}
@igmoweb
igmoweb / appointments.php
Created July 4, 2016 11:42
Update Event summary when an appointment is updatedRaw
<?php
add_filter( 'appointments_gcal_update_event', 'app_gcal_update_event_summary', 10, 2 );
function app_gcal_update_event_summary ( $event, $app ) {
if ( $event ) {
$appointments = appointments();
$event->setSummary( $appointments->get_service_name( $app->service ) . ' Appointment' );
}
return $event;
}
@igmoweb
igmoweb / app-hacks.php
Last active September 18, 2016 15:35
Appointments+: Automatically trigger Paypal button once confirmation is done
<?php
add_action( 'wp_footer', 'apppointmens_hacks_scripts', 20 );
function apppointmens_hacks_scripts() {
if ( wp_script_is( 'app-shortcode-confirmation', 'enqueued' ) ) {
?>
<script>
( function( $ ) {
$(document).on("app-confirmation-response_received", function() {
var paypalForm = $(".appointments-paypal > form");
checkURLs: function( urls ) {
var percentage;
if ( urls.length == 0 ) {
finiquitado();
return;
}
// Le robamos una URL a esto
var url = urls.shift();
@igmoweb
igmoweb / meta-query.php
Last active November 26, 2015 17:41
meta query
add_action( 'pre_get_posts', 'order_conciertos_by_date' );
function order_conciertos_by_date( $query ) {
if ( is_admin() )
return;
if ( $query->get( 'post_type' ) != 'concierto' )
return;
$today = current_time( 'timestamp' );
$today = date( 'Ymd', $today );
@igmoweb
igmoweb / clips.php
Last active November 26, 2015 16:45
clips
<?php
$args = array(
'post_type' => 'clips',
'ignore_sticky_posts' => true,
'posts_per_page' => 1,
'cat' => 6
);
$clips_query = new WP_Query( $args );
@igmoweb
igmoweb / new-blog-templates-gf.php
Created November 25, 2015 17:50
Gravity Forms + New Blog Templates Integration
<?php
// This should add a new option in the form feed but it doesn't anymore because the action has dissappeared
add_action( 'gform_user_registration_add_option_section', 'nbt_add_blog_templates_user_registration_option', 15 );
function nbt_add_blog_templates_user_registration_option( $config ) {
// I don't know if this would be valid in the new version
$multisite_options = rgar($config['meta'], 'multisite_options');
$my_option = rgar( $multisite_options, 'blog_templates' );
?>
<input type="checkbox" id="gf_user_registration_multisite_blog_templates" name="gf_user_registration_multisite_blog_templates" value="1" <?php checked( rgar( $multisite_options, 'blog_templates' ) ); ?> />
<?php
@igmoweb
igmoweb / extend-site-new.php
Last active December 14, 2015 18:58
Extend Site New Use case
<?php
add_action( 'network_after_site_new_form', function() {
$themes = wp_get_themes();
?>
<table class="form-table">
<tr class="form-field">
<th scope="row"><label for="my-plugin-theme">Select your theme</label></th>
<td>
<select name="my-plugin-theme" id="my-plugin-theme">
@igmoweb
igmoweb / site-new.php
Last active November 19, 2015 13:54
Custom query shortcode
<?php
add_shortcode( 'areas', 'custom_query_shortcode' );
function custom_query_shortcode( $atts ) {
// EXAMPLE USAGE:
// [areas show_posts="100" post_type="page" post_parent="246"]
// Defaults
$defaults = array(
"show_posts" => 100,
"post_type" => 'page',