Skip to content

Instantly share code, notes, and snippets.

View cliffordp's full-sized avatar

Clifford cliffordp

View GitHub Profile
@wpsmith
wpsmith / bail.php
Created August 1, 2012 17:47
Bail out if running an autosave, ajax or a cron for use in save_post
<?php
/**
* Bail out if running an autosave, ajax or a cron
* or user does not have proper capabilities
*
* @return bool|int True if should bail, post ID if lacking cap
*/
function wps_bail( $post_id = '', $cap = 'edit_post' ) {
/** Bail out if running an autosave */
@elimn
elimn / tribe_event_website_truncator.php
Created November 13, 2015 22:37
MT | TEC | Truncate lengthy Event Website URL Labels
<?php
/*
* Truncates (trims) the Event Website URL label when its too lengthy
*/
function tribe_event_website_truncator ( $label ) {
// Change this to adjust when the truncator starts trimming characters
$max_length = 25;
if( strlen($label) > $max_length ) {
@elimn
elimn / tribe_qr_scan_link.php
Created December 18, 2015 00:27
MT | ETP | Ties into the Zxing Barcode Scanner app for iOS and Android, allowing one-click scans
<?php
add_filter( 'pl_opt-textbox_title', 'hack_title' );
function hack_title( $opt ) {
global $post;
if( 4125 == $post->ID )
return 'Hello World!';
else
return $opt;
}
@barryhughes
barryhughes / cleanup-events-query.sql
Last active January 8, 2016 19:09
This query attempts to delete expired events with special handling for recurring events. Use at own risk!
-- Delete expired events.
--
-- Use at own risk and consider running on a test set of data first of all!
-- As is, should remove all events that have expired by more than one week,
-- with the exception of parent events for recurring events which will be
-- left in place.
--
-- Assumes a standard table prefix of "wp_" - adjust as required to match
-- your installation.
DELETE FROM wp_posts
@tevko
tevko / respsizes.js
Last active January 31, 2016 10:31
Dev Tools Snippet to auto-calculate responsive image sizes value on window resize
/**
*
* Paste image class / identifier in IIFE parenthesis at end of function
*
* */
(function(i){"use strict";var img=$(i),sizes=[];window.addEventListener("resize",()=>{var vw=Math.round(((img.offsetWidth*100)/window.innerWidth))+"vw",mq="(min-width: "+window.innerWidth+"px)",value=vw;vw!=="0vw"&&sizes.indexOf(vw)===-1&&(sizes.push(value),console.log(mq,vw))})})("PASTE CLASS OR IDENTIFIER HERE");
@ocean90
ocean90 / plugin.php
Created February 2, 2012 12:25
Remove gravatar from the WordPress Toolbar
<?php
/*
* Entfernt das Gravatar aus der Toolbar.
* @link: http://talkpress.de/artikel/wordpress-admin-bar-datenkrake-missbrauch
*/
/* < PHP 5.3 */
function ds_add_hide_avatar_filter() {
add_filter( 'pre_option_show_avatars', '__return_zero' );
}
add_action( 'woocommerce_share', 'patricks_woocommerce_social_share_icons', 10 );
function patricks_woocommerce_social_share_icons() {
if ( function_exists( 'sharing_display' ) ) {
remove_filter( 'the_content', 'sharing_display', 19 );
remove_filter( 'the_excerpt', 'sharing_display', 19 );
echo sharing_display();
}
}
<?php
class Section_Overide {
function __construct() {
add_filter( 'pagelines_render_section', array( $this, 'section_overide' ), 10, 2 );
}
function section_overide( $s, $class ) {
<?php
wp_oembed_add_provider( 'http://*.houzz.com/*', 'http://www.houzz.com/oembed' );
function do_houzz_shortcode($atts, $content=null) {
$url = substr( $atts[0], 1 );
$args = array();
if ( isset( $atts['w'] ) && is_numeric( $atts['w'] ) ) {
$args['width'] = $atts['w'];
}