This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Docs: https://docs.gravityforms.com/gform_display_product_summary/ | |
| # Disable for all forms | |
| add_filter( 'gform_display_product_summary', '__return_false' ); | |
| # Disable for a specific form | |
| add_filter( 'gform_display_product_summary', function( $display_product_summary, $field, $form, $entry ) { | |
| return $form['id'] == 10 ? false : $display_product_summary; | |
| }, 10, 4 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Change payment currency base from another field, when specific form is submitted. | |
| */ | |
| add_action( 'gform_pre_submission_2', 'change_currency_' ); | |
| function change_currency_( $form ) { | |
| add_filter( 'gform_currency', function() { return rgpost('input_4'); } ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function clean($string) { | |
| $string = str_replace(' ', '_', $string); // Replaces all spaces with hyphens. | |
| $string = preg_replace('/[^A-Za-z0-9_]/', '', $string); // Removes special chars. | |
| return preg_replace('/_+/', '_', $string); // Replaces multiple hyphens with single one. | |
| } | |
| echo clean("HAnn-a Jane##ll f. e"); // HAnna_Janell_f_e |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Limit maximum year to current year | |
| add_filter( 'gform_date_max_year', 'set_max_year' ); | |
| function set_max_year( $max_year ) { | |
| return date('Y', current_time('timestamp')); | |
| } | |
| // Reference: https://www.gravityhelp.com/documentation/article/gform_date_max_year/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Code placement: current theme functions.php | |
| // Change date displayed format. | |
| // Example adding a date field in a dropdown/datefield format is dd-mm-yy and value `09-09-2017`, | |
| // By adding this filter it will display as `09-September-2017`. | |
| // Take note that in gforms docs: https://www.gravityhelp.com/documentation/article/gform_merge_tag_filter/#5-date-field | |
| // priority is `10` and is working only for datepicker but not for dropdown and datefield, | |
| // here is changed to `15` to ensure filter would not be overriden. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getUrlParameter(name) { | |
| name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); | |
| var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); | |
| var results = regex.exec(location.search); | |
| return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); | |
| }; | |
| Reference: https://davidwalsh.name/query-string-javascript | |
| How to use ? | |
| // Assuming "?post=1234&action=edit" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Enqueue scripts and styles | |
| */ | |
| add_action( 'wp_enqueue_scripts', 'your_theme_enqueue_scripts' ); | |
| function your_theme_enqueue_scripts() { | |
| // all styles | |
| wp_enqueue_style( 'bootstrap', get_stylesheet_directory_uri() . '/css/bootstrap.css', array(), 20141119 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*******/ | |
| class GF_Field_SIN extends GF_Field { | |
| public $type = 'sin'; | |
| public function get_form_editor_field_title() { | |
| return esc_attr__( 'SIN', 'gravityforms' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| To make Postman work with POST/PUT requests... | |
| https://laravel.com/docs/5.2/routing#csrf-x-csrf-token | |
| In addition to checking for the CSRF token as a POST parameter, the Laravel VerifyCsrfToken middleware will also check for the X-CSRF-TOKEN request header. | |
| 1. Store the token in a "meta" tag at the top of your root view file (layouts/app.blade.php)... | |
| <meta name="csrf-token" content="{{ csrf_token() }}"> | |
| ** If using jQuery, you can now instruct it to include the token in all request headers. | |
| $.ajaxSetup({ |