Skip to content

Instantly share code, notes, and snippets.

View mgratch's full-sized avatar

Marc Gratch mgratch

View GitHub Profile
$.each($("table").find("td:nth-child(2)"),function(index,value){
if("action" === $(value).text()){
$(value).parents("tr").fadeOut();
}
});
@mgratch
mgratch / functions.php
Last active June 7, 2017 16:25
`gravityview/dt/index/skip` filter example
function only_skip_2871($view_id){
return '2871' == $view_id ? true : false;
}
add_filter( 'gravityview/dt/index/skip', 'only_skip_2871', 10 );
function skip_all_except_2871($view_id){
return '2871' == $view_id ? false : true;
}
add_filter( 'gravityview/dt/index/skip', 'skip_all_except_2871', 10 );
@mgratch
mgratch / sideload-gf-images.php
Created June 7, 2016 00:24
sideload images from gf multi-upload
<?php
add_filter( 'gform_save_field_value', 'save_field_value', 10, 4 );
function save_field_value( $value, $lead, $field, $form ) {
$output_ids = array();
global $files_to_sideload;
if(!isset($files_to_sideload) || empty($files_to_sideload)){
$files_to_sideload = array();
}
//if not the form with fields to encode, just return the unaltered value without checking the fields
@mgratch
mgratch / upload-gf.js
Last active June 6, 2016 22:12
create thumbnail when uploading image with GF multi file JS depen includ `array('jquery','gform_gravityforms','plupload-all')`
var count = 0;
var delete_buttons = [];
var dom = {
uploads: jQuery( "#gform_preview_2_1" )
};
(function($) {
function showImagePreview( file ) {
var target = "#"+file.id;
var item = $( "<li></li>" ).prependTo( target );
var title = $(target).find("strong").html();
@mgratch
mgratch / sg-push-wp-content-only.js
Last active February 7, 2017 03:59
Only check wp-content files when using advanced push for SiteGround staging.
var $ = jQuery;
$.each($(".databox").find("input[type='checkbox']"), function(){
var label = $(this).next("label").text();
if (label.indexOf('wp-content') > -1 && $(this).attr('disabled') !== true && $(this).attr('disabled') !== 'disabled'){
console.log('check-me');
$(this).attr('checked',true);
} else {
console.log('no-check');
$(this).attr('checked', false);
}
@mgratch
mgratch / functions.php
Last active December 18, 2015 17:50 — forked from dancameron/functions.php
Sprout Invoices Plugin/Theme Compatibility Example
<?php
/**
* Remove wp_footer hooks from an incompatible plugins and/or themes test test
*/
function remove_wp_footer_actions() {
if ( is_single() && ( SI_Invoice::is_invoice_query() || SI_Estimate::is_estimate_query() ) ) {
// plugins usually hook on the default priority, also
// core doesn't add anything on priority 10 so
// we can assume all hooks are from plugins and themes.
@mgratch
mgratch / custom-gvdt-script.js
Created December 8, 2015 05:32
front-end approval when using the datatables extension with additional colums added via `gravityview_datatables_js_options` filter
/**
* Custom js script at post edit screen
*
* @package gravityview-edit-datatables-options
* @license GPL2+
* @author Marc Gratch
* @link http://marcgratch.com
* @copyright Copyright 2015, Marc Gratch
*
* @since 1.0.0
@mgratch
mgratch / gravityview-edit-datatables-options.php
Last active November 20, 2015 03:55
Attempting to override the data source for dataTables view to allow for multi-column sort. This should be view agnostic, allowing for these options to override any datatable view.
<?php
/*
* Plugin Name: GravityView - Edit DataTables Options
* Plugin URI: http://gravityview.co/extensions/datatables/
* Description: This plugin is used to override the datatables data source and extend it.
* Version: 1.0
* Author: Katz Web Services, Inc. , Marc Gratch
* Author URI: http://www.katzwebservices.com
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
@mgratch
mgratch / unique-plugin_theme_files_custom-search.php
Last active September 25, 2015 02:27
Create a page, load a template file from plugin, pass input variables from one template to another via query_var
<?php
/**
* The template for displaying search results pages.
*
* @package WordPress
* @subpackage Twenty_Fifteen
* @since Twenty Fifteen 1.0
*/
get_header(); ?>
function add_referring_pic_data_query( $vars ){
$vars[] = "title";
$vars[] = 'description';
$vars[] = 'caption';
return $vars;
}
add_filter( 'query_vars', 'add_referring_pic_data_query' );