Skip to content

Instantly share code, notes, and snippets.

View benfavre's full-sized avatar
💻
At the office

Webdesign29 benfavre

💻
At the office
View GitHub Profile
@benfavre
benfavre / gist:2053331
Created March 16, 2012 22:39 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@benfavre
benfavre / gist:4161262
Created November 28, 2012 13:24
Wkhtmltopdf php example
<?php
ini_set('memory_limit', '210000M');
$command = "wkhtmltopdf-i386 --redirect-delay 100 --disable-smart-shrinking --print-media-type --margin-bottom 0mm --margin-left 0mm --margin-right 0mm --margin-top 0mm --dpi 96 'http://elwglobalarmour.com/shop/military-assault-vest/' /var/www/clients/carteweb.jeanstalaven.fr/www/2012_PDFHD/pdf-james.pdf";
exec($command);
$file = "/var/www/clients/carteweb.jeanstalaven.fr/www/2012_PDFHD/pdf-james.pdf";
@benfavre
benfavre / wd-video-import.json
Created December 18, 2012 11:55
Wd-video Json Pod Import
{"meta":{"version":"1.14.4","build":"1355831614"},"pods":{"1":{"name":"wd_video","label":"","is_toplevel":"1","detail_page":"","list_filters":"","pre_save_helpers":"","pre_drop_helpers":"","post_save_helpers":"","post_drop_helpers":"","fields":[{"name":"name","label":"Name","comment":null,"coltype":"txt","pickval":null,"weight":null,"display_helper":null,"input_helper":null,"pick_filter":null,"pick_orderby":null,"required":"1","unique":null,"multiple":null},{"name":"video_url_flv","label":null,"comment":null,"coltype":"txt","pickval":null,"weight":"4","display_helper":null,"input_helper":null,"pick_filter":null,"pick_orderby":null,"required":null,"unique":null,"multiple":null},{"name":"video_url_ogg","label":null,"comment":null,"coltype":"txt","pickval":null,"weight":"8","display_helper":null,"input_helper":null,"pick_filter":null,"pick_orderby":null,"required":null,"unique":null,"multiple":null},{"name":"video_length","label":null,"comment":null,"coltype":"txt","pickval":null,"weight":"11","display_helper":n
@benfavre
benfavre / pods2.x_gravityforms_helper.php
Last active December 10, 2015 05:58 — forked from anonymous/gravityforms.php
Pods 2.0 Gravity Forms input helper. Use a text or code field.
<?php
wp_enqueue_style( 'pods-select2' );
wp_enqueue_script( 'pods-select2' );
$attributes = array();
$attributes[ 'tabindex' ] = 2;
$pick_limit = (int) pods_var( 'pick_limit', $options, 0 );
$name .= '[]';
$attributes[ 'multiple' ] = 'multiple';
if ( !is_array( $options[ 'data' ] ) && false !== $options[ 'data' ] && 0 < strlen( $options[ 'data' ] ) )
@benfavre
benfavre / pods2.x_orderable_gravityforms_helper.php
Created December 28, 2012 14:07
Uses a hidden input and saves only the name. This one allows you to order the selection
<?php
wp_enqueue_style( 'pods-select2' );
wp_enqueue_script( 'pods-select2' );
$attributes = array();
$attributes[ 'type' ] = 'text';
$attributes[ 'value' ] = $value;
$attributes[ 'tabindex' ] = 2;
$attributes = PodsForm::merge_attributes( $attributes, $name, PodsForm::$field_type, $options );
@benfavre
benfavre / gravity_forms_bootstrap_wordpress.php
Created December 28, 2012 15:15
Add Bootstrap "btn" class to the submit input of gravity forms
// filter the Gravity Forms button type
add_filter("gform_submit_button", "form_submit_button", 10, 2);
function form_submit_button($button, $form){
return "<input type='submit' class='button gform_button btn btn-flat' id='gform_submit_button_{$form["id"]}' />";
}
@benfavre
benfavre / bulk_delete_adresses.js
Created February 7, 2013 12:36
Mailjet: Supprimer des adresses d'expédition en masse
// Use this script in the dev tools console in Google Chrome
// You might have to run it multiple times and refresh the page each time
table = $($0); // Select table with mail list in inspector
count = 0;
$('tr', table).each(function() {
row = $(this);
link = $('ul.dropdown-menu li:last-of-type a', row);
link_status = row.find(':nth-child(6)');
@benfavre
benfavre / load_async.js
Last active December 16, 2015 05:39 — forked from ngryman/snippet.js
Load Javascript files asynchonously
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(d, u) {
var s = d.scripts[0],
i = u.length, g;
@benfavre
benfavre / functions.php
Created April 22, 2013 18:36
Cleanup Shortcode #WordPress #functions.php
<?php
// A mettre dans functions.php
add_filter('the_content', 'clean_p_shortcode');
function clean_p_shortcode($content){
$array = array (
'<p>[' => '[',
']</p>' => ']',
']<br />' => ']'
);
/*
Allows for ajax requests to be run synchronously in a queue
Usage::
var queue = new $.AjaxQueue();
queue.add({
url: 'url',