Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate remainder of experimental snippets to appropriate folders with "Experimental Snippet πŸ§ͺ" flag. #993

Merged
merged 82 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
dcb3dc8
Tooling: Added experimental snippet migration script.
claygriffiths Jan 7, 2025
bc01a70
`gfjs-early-init-scripts.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
ec312cc
`gfsa-auto-allow-administrator-access.php`: Migrated from experimenta…
claygriffiths Jan 7, 2025
c80c9fb
`gpdec-delay-for-gravity-pdf-bg-processing.php`: Migrated from experi…
claygriffiths Jan 7, 2025
4f9adfb
`gpdtc-calculated-input-value.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
1232554
`gpi-auto-selections.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
7a56b87
`gpi-copy-exhausted-inventory-to-another-field.js`: Migrated from exp…
claygriffiths Jan 7, 2025
88ade22
`gpi-gpnf-exclude-child-entries-when-attached-to-a-partial-entry.php`…
claygriffiths Jan 7, 2025
e93571d
`gpi-packaged-products.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
ec5c112
`gpnf-comma-delimited-email-list.php`: Migrated from experimental fol…
claygriffiths Jan 7, 2025
538a624
`gpnf-count-answered-child-fields.js`: Migrated from experimental fol…
claygriffiths Jan 7, 2025
cd5560d
`gpnf-delete-expired-orphans.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
448650d
`gpnf-exclude-gf-inline-scripts-from-cloudflare-rocket-loader.php`: M…
claygriffiths Jan 7, 2025
668beca
`gpnf-gravity-view-values.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
8a853d6
`gpnf-gv-duplicate-child-entries.php`: Migrated from experimental fol…
claygriffiths Jan 7, 2025
73ab031
`gpnf-lock-child-entries-by-date.php`: Migrated from experimental fol…
claygriffiths Jan 7, 2025
9d6def7
`gpnf-modify-display-value-by-date.php`: Migrated from experimental f…
claygriffiths Jan 7, 2025
7c61aee
`gpnf-parent-form-field-values-in-child-form-filters.php`: Migrated f…
claygriffiths Jan 7, 2025
77c12e9
`gpnf-preserve-child-entry-created-by.php`: Migrated from experimenta…
claygriffiths Jan 7, 2025
734a708
`gpnf-restore-default-value-on-edit.php`: Migrated from experimental …
claygriffiths Jan 7, 2025
9807c1b
`gpnf-sortable-entries.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
71b7e5b
`gppa-acf-populate-multiple-items-from-repeater-row.php`: Migrated fr…
claygriffiths Jan 7, 2025
b383b51
`gppa-click-image-choice-image-wrapper.js`: Migrated from experimenta…
claygriffiths Jan 7, 2025
75e363f
`gppa-conditional-logic-when-no-results.js`: Migrated from experiment…
claygriffiths Jan 7, 2025
ef1069f
`gppa-conditionally-exclude-filter-by-field-value.php`: Migrated from…
claygriffiths Jan 7, 2025
74d5d9c
`gppa-enable-choice-values-for-gravity-view.php`: Migrated from exper…
claygriffiths Jan 7, 2025
1d70161
`gppa-faceted-filters.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
0b96c6f
`gppa-filter-entries-by-time-field.php`: Migrated from experimental f…
claygriffiths Jan 7, 2025
a8d4c68
`gppa-firefox-select-fixer.js`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
e7b8d73
`gppa-google-sheets-filter-by-date.php`: Migrated from experimental f…
claygriffiths Jan 7, 2025
c8f3c0c
`gppa-gv-display-field-value.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
364bc1a
`gppa-hydrate-choices-on-entry-list.php`: Migrated from experimental …
claygriffiths Jan 7, 2025
6484bca
`gppa-lmt-numbers-only-modifier.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
6adc638
`gppa-multi-file-value-as-links.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
9d9a6b5
`gppa-object-type-acf-options-page.php`: Migrated from experimental f…
claygriffiths Jan 7, 2025
f826b63
`gppa-object-type-json-api-with-query-params.php`: Migrated from expe…
claygriffiths Jan 7, 2025
9213927
`gppa-object-type-json-api.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
9ee1450
`gppa-page-modifier.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
f1b0c80
`gppa-populate-and-delete-coupons.php`: Migrated from experimental fo…
claygriffiths Jan 7, 2025
6ce19d4
`gppa-populate-date-in-fields-format.php`: Migrated from experimental…
claygriffiths Jan 7, 2025
cca94d3
`gppa-remove-filter-groups-with-missing-values.php`: Migrated from ex…
claygriffiths Jan 7, 2025
4847ee1
`gppa-select-all-checkboxes.js`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
68fb50e
`gppa-simply-schedule-appointments-refresh-lmts.js`: Migrated from ex…
claygriffiths Jan 7, 2025
38f5e61
`gppa-wc-country-to-gf-address-field.php`: Migrated from experimental…
claygriffiths Jan 7, 2025
cbe6b03
`gppa-woo-commerce-lmt.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
a3d9fe5
`gprf-reload-globally.js`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
707588b
`gpuid-belgium-cipher.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
c83718e
`gpuid-clear-index.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
8d9fda2
`gpuid-custom-format-ABC12345.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
eeae4a5
`gpwc-limit-line-breaks.js`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
49c1269
`gspc-remove-wc-product-from-entry-order-summary.php`: Migrated from …
claygriffiths Jan 7, 2025
3bafa74
`gspc-set-subscription-length-by-field-value.php`: Migrated from expe…
claygriffiths Jan 7, 2025
f818b1b
`gw-add-attachments-by-field.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
bdb6ca2
`gw-add-custom-footer-button.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
2b727d5
`gw-auto-prepend-https.js`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
c42036d
`gw-capture-file-extension.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
0101557
`gw-capture-filename.js`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
fdc21d8
`gw-capture-list-field-column-as-comma-delimited-list.php`: Migrated …
claygriffiths Jan 7, 2025
371cb7e
`gw-checkbox-to-list-field.js`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
1a6327a
`gw-count-sundays.js`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
18ba845
`gw-crazy-snippet.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
da8eb88
`gw-create-extra-entry.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
f695bcd
`gw-delete-entries-when-user-deleted.php`: Migrated from experimental…
claygriffiths Jan 7, 2025
d2dcf9c
`gw-field-ids-in-editor-labels.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
1c6597d
`gw-force-greater-end-time.js`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
0cd754b
`gw-force-numeric-keyboard-on-mobile.php`: Migrated from experimental…
claygriffiths Jan 7, 2025
27bb6fe
`gw-gfapc-map-multiple-fields-to-taxonomy.php`: Migrated from experim…
claygriffiths Jan 7, 2025
18c1b7d
`gw-gravity-forms-to-wp-job-manager.php`: Migrated from experimental …
claygriffiths Jan 7, 2025
2c60398
`gw-live-field-values-post-submission.php`: Migrated from experimenta…
claygriffiths Jan 7, 2025
9ff9b6c
`gw-minimum-file-count.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
c21520b
`gw-prevent-duplicate-drop-down-selections.js`: Migrated from experim…
claygriffiths Jan 7, 2025
df90b3f
`gw-prevent-non-numeric-chars.js`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
93205a6
`gw-preview-mode-tweaks.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
acf60ab
`gw-require-house-number-in-address.php`: Migrated from experimental …
claygriffiths Jan 7, 2025
2368855
`gw-rich-text-html-fields.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
6fa0ccd
`gw-round-total.js`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
999a2d2
`gw-use-html5-datepicker.js`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
b52ff65
`gw-validate-postcode.php`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
8f3f5a8
`gw-value-counter.js`: Migrated from experimental folder.
claygriffiths Jan 7, 2025
37a27d2
Formatting: Added placeholder files to `experimental` for snippets th…
claygriffiths Jan 7, 2025
5870000
Tooling: Removed experimental snippet migration script.
claygriffiths Jan 7, 2025
440ecd5
Formatting: Fixed some experimental snippets after migration.
claygriffiths Jan 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 4 additions & 28 deletions experimental/gfjs-early-init-scripts.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
<?php
/**
* Gravity Forms // Custom Javascript // Load Init Scripts Early
* https://gravitywiz.com/gravity-forms-code-chest/
*
* Some perks (e.g. Copy Cat, Address Autocomplete) allow their initialization options to be filtered but the Custom JS
* plugin outputs its scripts too late. This changes bumps GF Custom JS scripts to be output first.
*
* Developer Note: It's not possible to simply change the priority of the "gform_register_init_scripts" filter as
* field-based init scripts are registered before the filter is called.
*/
add_action( 'gform_register_init_scripts', function( $form ) {

$scripts = rgar( GFFormDisplay::$init_scripts, $form['id'] );
if ( empty( $scripts ) ) {
return;
}

$filtered = array();
foreach ( $scripts as $slug => $script ) {
if ( strpos( $slug, 'gf_custom_js' ) === 0 ) {
$filtered = array( $slug => $script ) + $filtered;
} else {
$filtered[ $slug ] = $script;
}
}

GFFormDisplay::$init_scripts[ $form['id'] ] = $filtered;

}, 100 /* right after GF Custom JS */ );
* We're no longer using the experimental folder for experimental snippets. 🚧
* You can now find the snippet here:
* https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gfjs-early-init-scripts.php
*/
8 changes: 3 additions & 5 deletions experimental/gfsa-auto-allow-administrator-access.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php
/**
* Gravity Forms // Submit to Access // Auto-allow Access for Administrators
* https://gravitywiz.com/submit-gravity-form-access-content/
* We're no longer using the experimental folder for experimental snippets. 🚧
* You can now find the snippet here:
* https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gfsa-auto-allow-administrator-access.php
*/
add_filter( 'gfsa_has_access', function( $has_access ) {
return current_user_can( 'administrator' );
} );
65 changes: 3 additions & 62 deletions experimental/gpdec-delay-for-gravity-pdf-bg-processing.php
Original file line number Diff line number Diff line change
@@ -1,65 +1,6 @@
<?php

/**
* Gravity Perks // Disable Entry Creation // Delay Deletion for Gravity PDF Background Processing
* http://gravitywiz.com/documentation/gravity-forms-disable-entry-creation/
*
* Prevent the deletion of entries until PDFs are generated and attached to notifications. This is necessary if
* using Gravity PDF's background processing as the entry will be deleted prior to the PDF being generated since
* background processing uses subsequent requests rather than form submission to generate the PDF.
*
* Installation instructions:
* 1. https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
* 2. See usage instructions at the bottom of the file
* We're no longer using the experimental folder for experimental snippets. 🚧
* You can now find the snippet here:
* https://github.com/gravitywiz/snippet-library/blob/master/gp-disable-entry-creation/gpdec-delay-for-gravity-pdf-bg-processing.php
*/
class GPDEC_GFPDF_Delayed_Deletion {
public $deletion_queue = array();
private $_args = array();

function __construct( $args ) {
$this->_args = wp_parse_args( $args, array(
'form_id' => false,
) );

add_action( 'init', array( $this, 'add_hooks' ), 16 ); // Wait for all add-ons
}

public function add_hooks() {
if ( ! function_exists( 'gp_disable_entry_creation' ) ) {
return;
}

add_filter( 'gpdec_should_delete_entry_' . $this->_args['form_id'], '__return_false' );
add_action( 'gfpdf_post_generate_and_save_pdf_notification', array( $this, 'post_generate_and_save' ), 50, 4 );
add_action( 'shutdown', array( $this, 'shutdown' ) );
}

public function post_generate_and_save( $form, $entry, $settings, $notifications ) {
if ( $form['id'] != $this->_args['form_id'] ) {
return;
}

$this->deletion_queue[] = $entry;
}

public function shutdown() {
if ( empty( $this->deletion_queue ) ) {
return;
}

foreach ( $this->deletion_queue as $entry ) {
gp_disable_entry_creation()->delete_form_entry( $entry );
}
}
}

/*
* Basic Usage
*
* Uncomment the lines below (remove the preceding // on each line) and adjust the form ID accordingly.
* You may also duplicate the class instantiation if this is required for more than one form.
*/

//new GPDEC_GFPDF_Delayed_Deletion( array(
// 'form_id' => 3,
//) );
6 changes: 3 additions & 3 deletions experimental/gpdtc-calculated-input-value.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* This snippet has evolved! πŸ¦„
* Find the new version of this snippet here:
* https://github.com/gravitywiz/snippet-library/blob/master/experimental/gpdtc-recalc.php
* We're no longer using the experimental folder for experimental snippets. 🚧
* You can now find the snippet here:
* https://github.com/gravitywiz/snippet-library/blob/master/gp-date-time-calculator/gpdtc-calculated-input-value.php
*/
71 changes: 3 additions & 68 deletions experimental/gpi-auto-selections.php
Original file line number Diff line number Diff line change
@@ -1,71 +1,6 @@
<?php
/**
* Gravity Perks // Inventory // Auto-selections
* https://gravitywiz.com/documentation/gravity-forms-inventory/
* We're no longer using the experimental folder for experimental snippets. 🚧
* You can now find the snippet here:
* https://github.com/gravitywiz/snippet-library/blob/master/gp-inventory/gpi-auto-selections.php
*/
global $gpias_form_id, $gpias_list_field_id, $gpias_product_field_id;

$gpias_form_id = 123;
$gpias_list_field_id = 4;
$gpias_product_field_id = 5;

add_filter( "gform_column_input_{$gpias_form_id}_{$gpias_list_field_id}_1", function( $input_info, $field, $column, $value, $form_id ) {
global $gpias_product_field_id;

$source_field = GFAPI::get_field( $form_id, $gpias_product_field_id );
$choices = $source_field->choices;

foreach ( $choices as &$choice ) {
if ( $source_field->enablePrice ) {
$price = rgempty( 'price', $choice ) ? 0 : GFCommon::to_number( rgar( $choice, 'price' ) );
$choice['value'] .= '|' . $price;
}
}

return array(
'type' => 'select',
'choices' => $choices,
);
}, 10, 5 );

add_filter( "gform_pre_process_{$gpias_form_id}", function( $form ) {
global $gpias_list_field_id, $gpias_product_field_id;

$list_field = GFAPI::get_field( $form, $gpias_list_field_id );
$booths = $list_field->get_value_submission( array() );

foreach ( $form['fields'] as $field ) {

if ( $field->id != $gpias_product_field_id ) {
continue;
}

while ( ! empty( $booths ) ) {

$booth = array_shift( $booths );
$_POST[ "input_{$field->id}" ] = $booth;

$_fields = $form['fields'];
$form['fields'] = array( $field );

$result = gp_inventory_type_choices()->validation( array(
'is_valid' => true,
'form' => $form,
) );

$form['fields'] = $_fields;

if ( $result['is_valid'] ) {
$field->failed_validation = false;
return $form;
}
}

if ( empty( $booths ) ) {
$list_field->failed_validation = true;
$list_field->validation_message = 'None of your selected booths are available.';
}
}

return $form;
} );
20 changes: 4 additions & 16 deletions experimental/gpi-copy-exhausted-inventory-to-another-field.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
/**
* Gravity Perks // Inventory // Copy Exhausted Choices to Another Field
* https://gravitywiz.com/documentation/gravity-forms-inventory/
*
* Instructions:
*
* 1. Install this snippet with our free Custom JavaScript plugin.
* https://gravitywiz.com/gravity-forms-code-chest/
* 2. Configure the snippet per the inline instructions.
*/
// Update "1" to the ID of your Inventory-enabled field.
var $disabled = $( '#input_GFFORMID_1 option:disabled' );

// Update "2" to the ID of the field to which exhausted choices should be copied.
$( '#input_GFFORMID_2' ).html( $disabled.clone().prop( 'disabled', false ) );

$disabled.remove();
* We're no longer using the experimental folder for experimental snippets. 🚧
* You can now find the snippet here:
* https://github.com/gravitywiz/snippet-library/blob/master/gp-inventory/gpi-copy-exhausted-inventory-to-another-field.js
*/
Original file line number Diff line number Diff line change
@@ -1,34 +1,6 @@
<?php
/**
* Gravity Perks // Inventory + Nested Forms // Exclude Child Entries of Partial Entry Parents from Inventory
* https://gravitywiz.com/documentation/gravity-forms-nested-forms/
*
* WIP: This provides very basic support for excluding child entries attached to a partial entry parent
* from inventory limits.
*
* @todo
*
* 1. Apply to all child forms without needing to specify a form ID.
* 2. Count child entries attached to the current partial entry.
* Support has been implemented when traversing between pages; however, the Nested Forms markup AJAX request
* is not aware of the current partial entry ID. Will need to pass this via the `gpnf_session_script_data`
* filter so it can be accessed
* We're no longer using the experimental folder for experimental snippets. 🚧
* You can now find the snippet here:
* https://github.com/gravitywiz/snippet-library/blob/master/gp-inventory/gpi-gpnf-exclude-child-entries-when-attached-to-a-partial-entry.php
*/
// Update "123" to your child form ID.
add_filter( 'gpi_query_123', function( $query, $field ) {
global $wpdb;
if ( class_exists( 'GF_Partial_Entries' ) ) {
if ( rgpost( 'partial_entry_id' ) ) {
$meta_value_clause = $wpdb->prepare( 'AND meta_value != %s', rgpost( 'partial_entry_id' ) );
}
$query['where'] .= "
AND e.id IN (
SELECT entry_id FROM {$wpdb->prefix}gf_entry_meta
WHERE meta_key = 'gpnf_entry_parent'
AND meta_value NOT IN(
SELECT entry_id FROM {$wpdb->prefix}gf_entry_meta WHERE meta_key = 'partial_entry_id' $meta_value_clause
)
)";
}
return $query;
}, 10, 2 );
Loading
Loading