Skip to content

Instantly share code, notes, and snippets.

@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 );
/*
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') ) );
}
@CoachBirgit
CoachBirgit / wp-api-custom-taxonomies.php
Created October 28, 2015 05:39 — forked from scottopolis/wp-api-custom-taxonomies.php
Add custom taxonomies to the WP-API
<?php
function ms_add_tax_to_api() {
$taxonomies = get_taxonomies( '', 'objects' );
foreach( $taxonomies as $taxonomy ) {
$taxonomy->show_in_rest = true;
}
}
add_action( 'init', 'ms_add_tax_to_api', 30 );
@CoachBirgit
CoachBirgit / vagrant-cheat-sheet.md
Last active October 28, 2015 10:21 — forked from wpscholar/vagrant-cheat-sheet.md
Vagrant Cheat Sheet

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Common Vagrant Commands

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
  • vagrant status -- outputs status of the vagrant machine
  • vagrant halt -- stops the vagrant machine
  • vagrant reload -- restarts vagrant machine, loads new Vagrantfile configuration
  • vagrant provision -- forces reprovisioning of the vagrant machine
@CoachBirgit
CoachBirgit / divi-nav-absolute-positioning.css
Last active November 5, 2015 07:13
DIVI: NAV - ABSOLUTE POSITIONING
/*DIVI NAV - ABSOLUTE POSITIONING*/
#main-header{
position:absolute;
}
.et-fixed-header{
top: 0;
background-color: #fff;
position: absolute; width: 100%;