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 / gist:5335793
Created April 8, 2013 10:26
Command for creating .POT file for the Pronamic iDEAL plugin.
find . -iname "*.php" -type f | xgettext \
--from-code=UTF-8 \
--keyword=__ \
--keyword=_e \
--keyword=_n:1,2 \
--keyword=_x:1,2c \
--keyword=_ex:1,2c \
--keyword=_nx:1,2,4c \
--default-domain=pronamic_ideal \
--language=PHP \
@remcotolsma
remcotolsma / jquery-ui-1.10.3.custom.min.js
Created May 7, 2013 09:33
Gravity Forms + Custom Post Types - fix has no method 'curCSS' - jquery-ui-1.10.3.custom.min.js
/*! jQuery UI - v1.10.3 - 2013-05-07
* http://jqueryui.com
* Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.position.js, jquery.ui.autocomplete.js, jquery.ui.menu.js
* Copyright 2013 jQuery Foundation and other contributors Licensed MIT */
(function(e,t){function i(t,i){var a,n,r,o=t.nodeName.toLowerCase();return"area"===o?(a=t.parentNode,n=a.name,t.href&&n&&"map"===a.nodeName.toLowerCase()?(r=e("img[usemap=#"+n+"]")[0],!!r&&s(r)):!1):(/input|select|textarea|button|object/.test(o)?!t.disabled:"a"===o?t.href||i:i)&&s(t)}function s(t){return e.expr.filters.visible(t)&&!e(t).parents().addBack().filter(function(){return"hidden"===e.css(this,"visibility")}).length}var a=0,n=/^ui-id-\d+$/;e.ui=e.ui||{},e.extend(e.ui,{version:"1.10.3",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32
@remcotolsma
remcotolsma / gist:5884430
Last active February 23, 2023 01:27
Gravity Forms calculate number days between 2 date fields
<script type="text/javascript">
jQuery( document ).ready( function( $ ) {
var ms_one_day = 1000 * 60 * 60 * 24;
var form_id = '1';
var date_format = 'dd-mm-yy';
var field_date_start = $( '#input_' + form_id + '_1' );
var field_date_end = $( '#input_' + form_id + '_2' );
@remcotolsma
remcotolsma / gist:6103897
Last active July 19, 2018 21:19
Analytics tracking code per language (WPML)
<?php
/**
* Google Analytics tracking code per language (WPML)
*
* @param array $options
* @see http://plugins.trac.wordpress.org/browser/google-analytics-for-wordpress/tags/4.3.3/frontend/class-frontend.php#L12
*/
function prefix_ga_init( $options ) {
global $yoast_ga;
@remcotolsma
remcotolsma / gist:6131041
Created August 1, 2013 12:51
Insert WordPress redirection items for the Redirection plugin (http://wordpress.org/plugins/redirection/) from WordPress post meta imported URL.
INSERT
INTO wp_redirection_items (
url ,
group_id ,
action_type ,
action_code ,
action_data ,
match_type
)
SELECT
@remcotolsma
remcotolsma / gist:6228437
Created August 14, 2013 06:11
Adjust WooCommerce gateway icon with the WooCommerce 'woocommerce_available_payment_gateways' filter.
<?php
function prefix_pronamic_ideal_gateway_icon( $gateways ) {
if ( isset( $gateways['pronamic_ideal'] ) ) {
$gateways['pronamic_ideal']->icon = get_stylesheet_directory_uri() . '/images/omnikassa.png';
}
return $gateways;
}
@remcotolsma
remcotolsma / gist:6460846
Last active December 22, 2015 10:48
WordPress action for WordPress User Query filter on author of specific post type.
<?php
/**
* User query post type
*
* @param WP_User_Query $query
* @see https://github.com/WordPress/WordPress/blob/3.6/wp-includes/user.php#L528
*/
function prefix_user_query_post_type( $query ) {
global $wpdb;
@remcotolsma
remcotolsma / gist:6460871
Created September 6, 2013 08:05
Example of WordPress action for WordPress User Query filter on author of specific post type. https://gist.github.com/remcotolsma/6460846
<?php
$user_query = new WP_User_Query( array(
'orderby' => 'ID',
'prefix_post_type' => 'blog'
) );
$users = $user_query->get_results();
foreach ( $users as $user ) {
@remcotolsma
remcotolsma / gist:6493015
Created September 9, 2013 08:38
WordPress function/action to exclude comment type in comment count.
<?php
/**
* Update comment count
*
* @see https://github.com/WordPress/WordPress/blob/3.6/wp-includes/comment.php#L1620
*/
function prefix_update_comment_count( $post_id ) {
global $wpdb;
SELECT
CONCAT(
'UPDATE wp_posts SET post_content = REPLACE(post_content, ' ,
QUOTE(meta.meta_value) , ', ' ,
QUOTE(post.guid) , ');'
)
FROM
wp_posts AS post
RIGHT JOIN
wp_postmeta AS meta