Skip to content

Instantly share code, notes, and snippets.

@travislopes
travislopes / ArchiveMenuFix.php
Last active August 29, 2015 14:00
WordPress filter for setting the proper CSS classes on post type archive menu items
<?php
/*
* Archive page in menu fix
* (requires menu item URL to be "/slug/")
*/
add_filter('nav_menu_css_class', function($classes, $item) {
global $wp_query;
// Loop through all the post types
foreach(get_post_types(null, 'objects') as $name => $post_type) {
( function( $ ) {
$( '#input_10_6' ).dropdown();
} )( jQuery );
<?php
add_action( 'gform_enqueue_scripts_10', 'enqueue_dropdown_script', 10, 2 );
function enqueue_dropdown_script( $form, $is_ajax ) {
wp_register_script( 'jquery-dropdown', 'js/jquery.dropdown.js', array( 'jquery' ) );
wp_enqueue_script( 'gform-jquery-dropdown', 'js/gravityforms.dropdown.js', array( 'jquery', 'jquery-dropdown' ) );
}
@travislopes
travislopes / GF_Easy_Form_Population.php
Created December 11, 2015 02:32
Populate form fields with values from a previous form entry
<?php
/**
* Gravity Forms Easy Form Population
*
* Populate form fields with values from a previous form entry.
*
* @version 1.0
* @author Travis Lopes <tl@travislop.es>
* @license GPL-2.0+
* @link http://travislop.es/
<?php
/**
* Gravity Forms Easy Form Population
*
* Populate form fields with values from a previous form entry.
*
* @version 1.0
* @author Travis Lopes <tl@travislop.es>
* @license GPL-2.0+
* @link http://travislop.es/
<?php
/**
* Gets Gravity Forms via form title.
*
* @access public
* @param string $title (default: null) - Form title to search for
* @param bool $return_form (default: false) - Return form object or form ID
* @return array - Array of form IDs or form objects (based on $return_form value)
*/
/**
* Custom account fields
*/
add_action( 'woocommerce_edit_account_form', 'my_woocommerce_edit_account_form' );
add_action( 'woocommerce_save_account_details', 'my_woocommerce_save_account_details' );
function my_woocommerce_edit_account_form() {
$user_id = get_current_user_id();
@travislopes
travislopes / Auto Open Field Settings.js
Last active February 24, 2017 21:45
This code snippet will automatically open the Gravity Forms field settings pane and navigate to the desired tab on page load.
/***
* This code snippet will automatically open the field settings
* pane and navigate to the desired tab on page load.
*
* To use, just add the tab to the hash of the page URL:
* http://example.com/wp-admin/admin.php?page=gf_edit_forms&id=1#tab=gform_tab_1
*
* By default, the first field in the form will be opened.
* To open a different field, add a field ID parameter:
* http://example.com/wp-admin/admin.php?page=gf_edit_forms&id=1#tab=gform_tab_1&field=4
<?php
add_filter( 'fg_entryautomation_export_email_message', 'add_payment_summary', 10, 4 );
function add_payment_summary( $message, $settings, $form, $file_name ) {
// Get search criteria.
$search_criteria = fg_entryautomation()->get_search_criteria( $settings, $form );
// Get entries for search criteria.
<?php
add_filter( 'fg_entryautomation_maximum_attachment_size', 'increase_attachment_size', 10, 4 );
function increase_attachment_size( $maximum_file_size, $settings, $form, $file_name ) {
return 10485760;
}