Skip to content

Instantly share code, notes, and snippets.

View remcotolsma's full-sized avatar
🏢
Working @pronamic

Remco Tolsma remcotolsma

🏢
Working @pronamic
View GitHub Profile
@remcotolsma
remcotolsma / functions.php
Last active August 29, 2015 13:58
Gravity Forms readonly fields (no JavaScript).
<?php
/**
* Read only
*
* @param string $field_content
* @param array $field
* @return string
*/
function prefix_gform_field_readonly( $field_content, $field ) {
<?php
// With this filter you check wich filter breaks 'the_content'
function test_the_content( $content ) {
echo strlen( $content ), '<br />';
}
add_filter( 'the_content', 'test_the_content', 0 );
add_filter( 'the_content', 'test_the_content', 1 );
add_filter( 'the_content', 'test_the_content', 10 );
@remcotolsma
remcotolsma / gist:8577520
Created January 23, 2014 12:05
WordPress quick lookup hooks.
<?php
// Add at bottom of https://github.com/WordPress/WordPress/blob/3.8/wp-settings.php
$ip = $_SERVER['REMOTE_ADDR'];
if ( $ip == '0.0.0.0' ) {
// Test hook function
function test_filter_test() {
var_dump( $_POST );
@remcotolsma
remcotolsma / functions.php
Created January 14, 2014 15:42
Override WooCommerce "Sale!" text.
<?php
function prefix_woocommerce_sale_flash( $text ) {
$text = '<span class="onsale">'. __( 'Action!', 'text_domain' ). '</span>';
return $text;
}
add_filter( 'woocommerce_sale_flash', 'prefix_woocommerce_sale_flash' );
@remcotolsma
remcotolsma / gist:8301328
Last active January 2, 2016 12:09
WP-Poll vote count distinct IP.
SELECT
vote.pollip_qid,
vote.pollip_aid,
answer.polla_answers,
COUNT( DISTINCT vote.pollip_ip )
FROM
wp_pollsa AS answer
LEFT JOIN
wp_pollsip AS vote
ON answer.polla_aid = vote.pollip_aid
@remcotolsma
remcotolsma / wpe-db-debug.php
Created December 24, 2013 10:41
WP Engine database debug file with whitespace after PHP close tag.
<?php
/*
Plugin Name: Wink Bedug Crap
Description: Blah blah
*/
if( isset( $_REQUEST["wpe_check_hooks"] ) ) {
global $wink;
if( empty( $wink ) ) {
//we need to set some starting variables here
$wink = new stdClass();
@remcotolsma
remcotolsma / gravityforms-unique.php
Last active March 31, 2022 07:54
Gravity Forms check on unique email and categoryf field.
<?php
/**
* Hooks into the "gform_validation" filter to test whether or not a new lead is a duplicate of another lead
* based upon their fields.
*
* @param mixed $validation_result
*
* @return mixed $validation_result
*/
@remcotolsma
remcotolsma / gist:7230462
Last active December 26, 2015 23:29
Pronamic iDEAL version 2.0 fix double payments conversion to custom post type.
-- Delete payments post meta lower then specific post ID
DELETE FROM wp_postmeta WHERE post_id IN ( SELECT ID FROM wp_posts WHERE post_type = 'pronamic_payment' AND post_date <= '2013-11-14 15:34:26' );
-- Delete payments posts lower then specific post ID
DELETE FROM wp_posts WHERE post_type = 'pronamic_payment' AND post_date <= '2013-11-14 15:34:26';
-- Update the payments post ID reference
UPDATE wp_pronamic_ideal_payments SET post_id = null WHERE post_id NOT IN ( SELECT ID FROM wp_posts );
-- Reset the database version option
@remcotolsma
remcotolsma / gist:6896886
Created October 9, 2013 06:04
WordPress add 'id' attribute to Vimeo oEmbed HTML.
<?php
/**
* Add 'id' attribute to Vimeo oEmbed HTML
*/
function prefix_embed_oembed_html( $html, $url, $attr, $post_ID ) {
$fix = true;
$fix &= strpos( $html, 'vimeo.com' ) !== false; // Embed code from Vimeo
$fix &= strpos( $html, ' id=' ) === false; // No ID attribute supplied by Vimeo
$fix &= isset( $attr['player_id'] ); // Player ID supplied
@remcotolsma
remcotolsma / gist:6896862
Created October 9, 2013 06:02
WordPress enable Vimeo API for oEmbed
<?php
/**
* Enable Vimeo API for oEmbed
*/
function prefix_oembed_enable_vimeo_api( $provider, $url, $args ) {
if ( strpos( $provider, 'vimeo.com' ) ) {
$provider = add_query_arg( array(
'api' => '1',
'player_id' => isset( $args['player_id'] ) ? $args['player_id'] : false