Skip to content

Instantly share code, notes, and snippets.

@CoachBirgit
CoachBirgit / functions.php
Last active April 16, 2018 17:21
WordPress: Add 'img-responsive' class via filter to 'the_content'
// add default class for img-responsive
function add_image_responsive_class($content) {
global $post;
$pattern ="/<img(.*?)class=\"(.*?)\"(.*?)>/i";
$replacement = '<img$1class="$2 img-responsive"$3>';
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
add_filter('the_content', 'add_image_responsive_class');
@CoachBirgit
CoachBirgit / functions.php
Last active August 29, 2015 14:13
WordPress: make post-thumbnails responsive by default
/* make post-thumbnails responsive by default */
add_filter('post_thumbnail_html','tm_add_class_to_thumbnail');
function tm_add_class_to_thumbnail($thumb) {
$thumb = str_replace('attachment-', 'img-responsive attachment-', $thumb);
return $thumb;
}
/**
* Responsive WordPress Core Theme Styles
* http://jeffsebring.com/responsive-wordpress-images/
--------------------------------------------------- */
.sticky,
.bypostauthor,
.gallery-caption {
display: normal;
}
@CoachBirgit
CoachBirgit / 0_reuse_code.js
Last active August 29, 2015 14:17
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
// API Request
$url = 'http://localhost/um-api/get.user/?id=1';
// Include your public key and token to the URL
$url = add_query_arg('key', '75d9a913782eee3d990e4464ce26213e', $url );
$url = add_query_arg('token', 'bae6ee38cf02a50a0ac8259eed34ceb9', $url );
// Process your request
$request = wp_remote_get( $url );
$response = json_decode( wp_remote_retrieve_body( $request ) , true );
@CoachBirgit
CoachBirgit / divi-sticky-footer.css
Last active January 6, 2018 02:11
CSS: Sticky footer - Elegantthemes Divi
@CoachBirgit
CoachBirgit / gist:f1b94ccb22dc8d653fa3
Created July 6, 2015 10:20
Ultimate Member Private Messages: dynamic message button by passing dynamic user ID
<?php echo do_shortcode('[ultimatemember_message_button user_id='.$user_id.']'); ?>
/*
This code sample shows you how to use the API to create
and add custom notifications (for real-time notifications)
plugin.
STEP 1: You need to extend the filter: um_notifications_core_log_types with your
new notification type as follows for example
*/
/* This example syncs both UM / WP role during user approval */
add_action('um_after_user_is_approved', 'sync_um_and_wp_role', 99 );
function sync_um_and_wp_role( $user_id ) {
// Get UM role
$role = get_user_meta( $user_id, 'role', true );
// Set WordPress role for same user
$wp_user_object = new WP_User( $user_id );
add_action('um_submit_form_errors_hook', 'check_customer_code', 100 );
function check_customer_code( $args ){
if ( isset( $args['customer_code'] ) && $args['customer_code'] != 'ABCDE' )
exit( wp_redirect( add_query_arg('err', 'invalid_customer_code') ) );
}