Skip to content

Commit

Permalink
~ Run PHPCBF (composer lint:fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
claygriffiths committed Feb 7, 2022
1 parent 5395619 commit 99137d3
Show file tree
Hide file tree
Showing 154 changed files with 1,936 additions and 1,934 deletions.
2 changes: 1 addition & 1 deletion experimental/gpdtc-recalc.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Re-calculate a GPDTC calculated field dynamically every time it's viewed.
*/
add_action( 'wp_loaded', function() {
$form_id = 13; // Change this to the form's ID
$form_id = 13; // Change this to the form's ID
$field_id = 132; // Change this to the Age's field ID
if ( class_exists( 'GP_Date_Time_Calculator' ) ) {
$values = array();
Expand Down
4 changes: 2 additions & 2 deletions experimental/gpepee-conditional-edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/**
* Gravity Perks // Easy Passthrough Edit Entry // Conditional Edit
* https://gravitywiz.com/edit-gravity-forms-entries-on-the-front-end/
*
* Create a field on your form and check for a specific value on that field to determine if the passed
*
* Create a field on your form and check for a specific value on that field to determine if the passed
* through entry should be edited or if a new entry should be created.
*/
// Update "123" to the form you are using to edit entries.
Expand Down
21 changes: 11 additions & 10 deletions experimental/gpi-auto-selections.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/
global $gpias_form_id, $gpias_list_field_id, $gpias_product_field_id;

$gpias_form_id = 123;
$gpias_list_field_id = 4;
$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 ) {
Expand All @@ -32,7 +32,7 @@
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() );
$booths = $list_field->get_value_submission( array() );

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

Expand All @@ -42,28 +42,29 @@

while ( ! empty( $booths ) ) {

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

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

$result = gp_inventory_type_choices()->validation( array( 'is_valid' => true, 'form' => $form ) );
$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->failed_validation = true;
$list_field->validation_message = 'None of your selected booths are available.';
}

}

return $form;
Expand Down
16 changes: 8 additions & 8 deletions experimental/gpi-packaged-products.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ public function __construct( $args = array() ) {
public function init() {
add_filter( 'gpi_claimed_inventory_' . $this->form_id, array(
$this,
'package_field_claimed_inventory'
'package_field_claimed_inventory',
), 10, 2 );

add_filter( 'gpi_claimed_inventory_' . $this->form_id, array(
$this,
'add_claimed_package_inventory_to_individual_products'
'add_claimed_package_inventory_to_individual_products',
), 10, 2 );

add_filter( 'gpi_requested_quantity_' . $this->form_id, array(
$this,
'add_requested_packages_to_individual_products'
'add_requested_packages_to_individual_products',
), 10, 2 );
}

Expand All @@ -70,7 +70,7 @@ public function package_field_claimed_inventory( $package_claimed_inventory, $fi

remove_filter( 'gpi_claimed_inventory_' . $this->form_id, array(
$this,
'add_claimed_package_inventory_to_individual_products'
'add_claimed_package_inventory_to_individual_products',
) );

$inventory_limit = gp_inventory_type_advanced()->get_stock_quantity( $this->package_field );
Expand All @@ -92,7 +92,7 @@ public function package_field_claimed_inventory( $package_claimed_inventory, $fi

add_filter( 'gpi_claimed_inventory_' . $this->form_id, array(
$this,
'add_claimed_package_inventory_to_individual_products'
'add_claimed_package_inventory_to_individual_products',
), 10, 2 );

return $package_claimed_inventory;
Expand All @@ -108,14 +108,14 @@ public function add_claimed_package_inventory_to_individual_products( $claimed_i

remove_filter( 'gpi_claimed_inventory_' . $this->form_id, array(
$this,
'package_field_claimed_inventory'
'package_field_claimed_inventory',
) );

$claimed_packages_inventory = gp_inventory_type_advanced()->get_claimed_inventory( $this->package_field );

add_filter( 'gpi_claimed_inventory_' . $this->form_id, array(
$this,
'package_field_claimed_inventory'
'package_field_claimed_inventory',
), 10, 2 );

return (int) $claimed_inventory + (int) $claimed_packages_inventory;
Expand All @@ -142,5 +142,5 @@ public function add_requested_packages_to_individual_products( $requested_quanti
new GP_Inventory_Packaged_Products( array(
'form_id' => 2,
'package_field_id' => 4,
'field_ids_in_package' => array( 1, 2 )
'field_ids_in_package' => array( 1, 2 ),
) );
10 changes: 5 additions & 5 deletions experimental/gpml-auto-add-terms.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<?php
/**
* Gravity Perks // Media Library // Add terms to new Media Library files.
* https://gravitywiz.com/documentation/gravity-forms-media-library/
* https://gravitywiz.com/documentation/gravity-forms-media-library/
*/
// Update "123" to your form ID and "4" to your GPML-enabled File Upload field.
add_action( 'gpml_media_data_123_4', function( $gpml_media_data ) {
$terms = array(
$terms = array(
'category' => array(
'Red',
'Green',
'Blue'
'Blue',
),
'post_tag' => array(
'Small',
'Medium',
'Large'
)
'Large',
),
);
$gpml_media_data['post_data']['tax_input'] = $terms;
return $gpml_media_data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
add_filter( 'wp_inline_script_attributes', function ( $attributes, $javascript ) {
if ( strpos( $javascript, 'gform.' ) ) {
$attributes['data-cfasync'] = 'false';
$attributes['data-cfasync'] = 'false';
}
return $attributes;
}, 10, 2 );
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
add_filter( 'gppa_input_choices_123_4', function( $choices, $field, $objects ) {
$filtered = array();
foreach ( $choices as $choice ) {
$index = explode( '_', $choice['object']['meta_key'] )[1];
$is_available = (bool) get_post_meta( $choice['object']['post_id'],substr( $choice['object']['meta_key'], 0, -5 ) . 'tillganglighet', true );
$index = explode( '_', $choice['object']['meta_key'] )[1];
$is_available = (bool) get_post_meta( $choice['object']['post_id'], substr( $choice['object']['meta_key'], 0, -5 ) . 'tillganglighet', true );
if ( $is_available ) {
$title = get_post_meta( $choice['object']['post_id'], "plats_{$index}_plats_och_datum_plats", true );
$choice['text'] .= sprintf( ' (%s)', $title );
Expand Down
6 changes: 3 additions & 3 deletions experimental/gppa-enable-choice-values-for-gravity-view.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This snippet dynamically enables the choice value setting for GPPA-enabled fields so that GravityView
* This snippet dynamically enables the choice value setting for GPPA-enabled fields so that GravityView
* will present the option to show the value or label when including this field in a view.
*
*
* See: https://secure.helpscout.net/conversation/1511770443/24411/#thread-4407403575
*/
add_filter( 'gform_form_post_get_meta', function( $form ) {
Expand All @@ -21,6 +21,6 @@
$field->enableChoiceValue = true;
}
}

return $form;
} );
2 changes: 1 addition & 1 deletion experimental/gppa-gv-display-field-value.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

// Update "123" to your form ID. Update to "4", "5", and "6" to your field IDs.
$targets = array(
123 => array( 4, 5, 6 )
123 => array( 4, 5, 6 ),
);

if ( ! function_exists( 'gravityview' ) || ! gravityview()->request->is_view() ) {
Expand Down
6 changes: 3 additions & 3 deletions experimental/gppa-multi-file-value-as-links.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
/**
* Gravity Perks // Populate Anything // Format Comma-delimited List of Files as Links
* https://gravitywiz.com/documentation/gravity-forms-populate-anything/
*
*
* Populate a Single Line Text field with the value of a Multi-file Upload field and then use this snippet to display
* the file URLs as links instead of plain text.
*/
// Update "123" to your form ID and "4" to the field ID being populated with your file URLs.
add_filter( 'gppa_live_merge_tag_value_348_2', function( $merge_tag_match_value, $merge_tag, $form, $field_id, $entry_values ) {
$urls = explode( ', ', $merge_tag_match_value );
$urls = explode( ', ', $merge_tag_match_value );
$links = array();
foreach ( $urls as $url ) {
$links[] = sprintf( '<a href="%s">%s</a>', $url, basename( $url ) );
}
return implode( "<br>", $links );
return implode( '<br>', $links );
}, 10, 5 );
32 changes: 16 additions & 16 deletions experimental/gppa-object-type-acf-options-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Advanced Custom Fields. For more on Options Pages, see https://www.advancedcustomfields.com/resources/options-page/
*
* Installation: https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
*
*
* Known Limitations:
* * Filtering is not supported with this Object Type
*/
Expand All @@ -29,24 +29,24 @@ public function get_options_pages() {
}

public function get_properties( $options_page = null ) {
$field_groups = acf_get_field_groups(array(
'options_page' => $options_page
));
$field_groups = acf_get_field_groups(array(
'options_page' => $options_page,
));

$properties = array();
$properties = array();

foreach ( $field_groups as $field_group ) {
$fields = acf_get_fields( $field_group );
foreach ( $field_groups as $field_group ) {
$fields = acf_get_fields( $field_group );

foreach ( $fields as $field ) {
$properties[ $field['name'] ] = array(
'value' => $field['name'],
'label' => $field['label'],
'callable' => '__return_false',
'orderby' => false,
);
}
}
foreach ( $fields as $field ) {
$properties[ $field['name'] ] = array(
'value' => $field['name'],
'label' => $field['label'],
'callable' => '__return_false',
'orderby' => false,
);
}
}

return $properties;
}
Expand Down
8 changes: 4 additions & 4 deletions experimental/gppa-populate-date-in-fields-format.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
add_filter( 'gppa_process_template_value', function( $value, $field ) {
if ( $field->get_input_type() === 'date' && $field->dateType === 'datepicker' ) {
list( $format, $separator ) = array_pad( explode( '_', $field->dateFormat ), 2, 'slash' );
$separators = array(
$separators = array(
'slash' => '/',
'dash' => '-',
'dot' => '.',
);
$format = str_replace( 'y', 'Y', $format );
$format = implode( $separators[ $separator ], str_split( $format ) );
$value = date( $format, strtotime( $value ) );
$format = str_replace( 'y', 'Y', $format );
$format = implode( $separators[ $separator ], str_split( $format ) );
$value = date( $format, strtotime( $value ) );
}
return $value;
}, 10, 2 );
2 changes: 1 addition & 1 deletion experimental/gppa-wc-country-to-gf-address-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Update "26" to your Address field ID. Leave the ".6" alone.
add_filter( 'gppa_process_template_26.6', function( $template_value, $field, $template_name, $populate, $object, $object_type, $objects, $template ) {
if ( $template === 'meta_billing_country' ) {
$countries = GF_Fields::get( 'address' )->get_default_countries();
$countries = GF_Fields::get( 'address' )->get_default_countries();
$template_value = rgar( $countries, $template_value, $template_value );
}
return $template_value;
Expand Down
8 changes: 5 additions & 3 deletions experimental/gppa-woo-commerce-lmt.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
* See: https://secure.helpscout.net/conversation/1520295750/24633?folderId=3808239
*/
add_action( 'wp', function() {
if ( ! function_exists('WC' ) || ( ! is_cart() && ! is_checkout() ) ) return;
if ( ! function_exists( 'WC' ) || ( ! is_cart() && ! is_checkout() ) ) {
return;
}
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
add_filter( 'gform_pre_render', function( $form ) use ($cart_item) {
add_filter( 'gform_pre_render', function( $form ) use ( $cart_item ) {
$gravity_form_data = $cart_item['_gravity_form_data'];
$form_meta = RGFormsModel::get_form_meta( $gravity_form_data['id'] );
$form_meta = RGFormsModel::get_form_meta( $gravity_form_data['id'] );
foreach ( $form_meta['fields'] as $field_index => $field ) {
if ( ! $field['choices'] ) {
continue;
Expand Down
14 changes: 8 additions & 6 deletions experimental/gpuid-clear-index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
* Clear all indexes for GPUID.
*/
add_action( 'admin_init', function() {
if ( ! rgget( 'gpuid_clear_indexes' ) ) return;
if ( ! rgget( 'gpuid_clear_indexes' ) ) {
return;
}
// Ensure GPUID is disabled
if ( class_exists( 'GP_Unique_ID' ) ) {
wp_redirect( '/wp-admin/plugins.php?plugin_status=active&guid_clear_indexes_error_active=true' );
Expand All @@ -30,24 +32,24 @@
} );

add_action( 'admin_notices', function ( $messages ) {
if ( rgget( 'guid_clear_indexes_error_active' ) ):
if ( rgget( 'guid_clear_indexes_error_active' ) ) :
?>
<div class="notice notice-error">
<p>Please disable GP Unique ID before attempting to clear the indexes.</p>
</div>
<?php
elseif ( rgget( 'guid_clear_indexes_success' ) ):
elseif ( rgget( 'guid_clear_indexes_success' ) ) :
?>
<div class="notice notice-success">
<p>GP Unique ID table indexes were cleared. Please de-activate this snippet and enable GPUID again.</p>
</div>
<?php
else:
<?php
else :
?>
<div class="notice">
<p>GP Unique ID Clear Indexes snippet is active. If you have already cleared the indexes please remove it.
Otherwise you can <a href="/wp-admin/plugins.php?gpuid_clear_indexes=true">start clearing indexes here</a>.</p>
</div>
<?php
<?php
endif;
} );
8 changes: 4 additions & 4 deletions experimental/gpuid-custom-format-ABC12345.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?php
/**
* Gravity Perks // Unique ID // Custom Format: `ABC12345`
*
* Generate a Unique ID in the following format `ABC12345` where each letter can be any letter between A and Z and each
*
* Generate a Unique ID in the following format `ABC12345` where each letter can be any letter between A and Z and each
* digit can be any number between 1 and 9.
*
*
* Configuration instructions are inline.
*/
add_filter( 'gpui_unique_id', function( $unique, $form_id, $field_id ) {
// Update the "123" to your form ID and the "4" to your Unique ID field's ID.
if ( $form_id == 123 && $field_id == 4 ) {
$unique = '';
foreach( range( 0, 2 ) as $index ) {
foreach ( range( 0, 2 ) as $index ) {
$unique .= chr( rand( 65, 90 ) );
}
$unique .= rand( 10000, 99999 );
Expand Down
Loading

0 comments on commit 99137d3

Please sign in to comment.