Skip to content

Instantly share code, notes, and snippets.

@jeremyfelt
jeremyfelt / gist:2353300
Created April 10, 2012 18:05
Strip whitespace between HTML tags in wp_nav_menu()
<?php
/* Modify the output of list items in the header navigation menu.
*
* Remove the whitespace between HTML tags. Required specifically for better
* behavior when list items are inline-block in our main nav menu and need
* the browsers to adhere to exact margins.
*
* NOTE: filter name changes depending on your menu - this one works for 'navigation_items'
*/
@viruthagiri
viruthagiri / filter_wpmu_signup_user_notification.php
Created February 7, 2012 18:29
Change the default WordPress MultiSite user notification mail from using the main network admin_email and site_name to the blog admin_email & blogname.
<?php
add_filter( 'wpmu_signup_user_notification', 'dk_wpmu_signup_user_notification', 10, 4 );
/**
* Problem: WordPress MultiSite sends user signup mails from the main site. This is a problem when using domain mapping functionality as the sender is not the same domain as expected when creating a new user from a blog with another domain.
* Solution: Change the default user notification mail from using the main network admin_email and site_name to the blog admin_email & blogname
*
* @author Daan Kortenbach
* @link http://daankortenbach.nl/wordpress/filter-wpmu_signup_user_notification/
*/
function dk_wpmu_signup_user_notification($user, $user_email, $key, $meta = '') {
@zlove
zlove / gist:3b9b6a611715ec3a8a60
Last active February 25, 2020 22:53
Preview WooCommerce Emails
<?php
/**
* Quick hack to preview WooCommerce e-mails.
* Based on drrobotnik's answer from Stack Overflow: http://stackoverflow.com/a/27072101/186136
*
* Add this to <yourtheme>/functions.php and then visit a url like:
* http://<site_url>/wp-admin/admin-ajax.php?action=previewemail
*
* @return null
*/
@benhuson
benhuson / cust-vimeo-oembed
Last active April 18, 2020 23:30
Customise WordPress Vimeo oEmbed
<?php
/**
* Customise WordPress Vimeo oEmbed
* https://developer.vimeo.com/apis/oembed
*/
function my_oembed_fetch_url( $provider, $url, $args ) {
if ( strpos( $provider, 'vimeo.com' ) !== false) {
$wp_customize->add_setting( 'themeslug_media_setting_id', array(
'sanitize_callback' => 'absint',
'validate_callback' => 'themeslug_validate_image,
) );
$wp_customize->add_control(
new WP_Customize_Media_Control( $wp_customize, 'themeslug_media_setting_id', array(
'label' => __( 'Custom Core Media Setting' ),
'section' => 'custom_section', // Add a default or your own section
'mime_type' => 'image',
@vegaskev
vegaskev / functions.php
Created July 20, 2018 22:05
Change Gravity Forms Spinner to CSS Spinner
// Changes Gravity Forms Ajax Spinner (next, back, submit) to a transparent image
// this allows you to target the css and create a pure css spinner like the one used below in the style.css file of this gist.
add_filter( 'gform_ajax_spinner_url', 'spinner_url', 10, 2 );
function spinner_url( $image_src, $form ) {
return 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'; // relative to you theme images folder
}
@helgatheviking
helgatheviking / kia_add_script_to_footer.php
Created February 24, 2017 18:09
Add plus and minus buttons to WooCommerce quantity inputs
@mannieschumpert
mannieschumpert / gist:8334811
Last active August 20, 2023 14:58
Filter the submit button in Gravity Forms to change the <input type="submit> element to a <button> element. There's an example in the Gravity Forms documentation, but it lacks the proper code to show your custom button text, AND removes important attributes like the onclick that prevents multiple clicks. I was trying to solve that.
<?php
// filter the Gravity Forms button type
add_filter("gform_submit_button", "form_submit_button", 10, 2);
function form_submit_button($button, $form){
// The following line is from the Gravity Forms documentation - it doesn't include your custom button text
// return "<button class='button' id='gform_submit_button_{$form["id"]}'>'Submit'</button>";
// This includes your custom button text:
return "<button class='button' id='gform_submit_button_{$form["id"]}'>{$form['button']['text']}</button>";
}
// Oops this strips important stuff
@mkkeck
mkkeck / class-editor-social-link.php
Last active January 14, 2024 13:48
Patched WordPress block `core/social-link` to allow theme developers to register own social services
@cferdinandi
cferdinandi / stop-video.js
Last active February 15, 2024 17:03
A simple method to stop YouTube, Vimeo, and HTML5 videos from playing.
/**
* Stop an iframe or HTML5 <video> from playing
* @param {Element} element The element that contains the video
*/
var stopVideo = function ( element ) {
var iframe = element.querySelector( 'iframe');
var video = element.querySelector( 'video' );
if ( iframe ) {
var iframeSrc = iframe.src;
iframe.src = iframeSrc;