Disable Copy Cat When Editing.

Removes copy cat functionality on Entry Blocks’ Edit Page.

Code

Filename: gpeb-disable-copy-cat-edit.php

<?php
/**
 * Gravity Perks // Entry Blocks // Disable Copy Cat When Editing.
 * https://gravitywiz.com/documentation/gravity-forms-entry-blocks/
 *
 * Removes copy cat functionality on Entry Blocks' Edit Page.
 */
add_filter( 'gpeb_edit_form', function ( $form ) {
	foreach ( $form['fields'] as &$field ) {
		// remove any of the copy cat classes from the field.
		preg_match_all( '/copy-([0-9]+(?:.[0-9]+)*)-to-([0-9]+(?:.[0-9]+)*)(?:-if-([0-9]+(?:.[0-9]+)*))?/', $field['cssClass'], $matches, PREG_SET_ORDER );
		if ( empty( $matches ) ) {
			continue;
		}
		$field['cssClass'] = str_replace( $matches[0], '', $field['cssClass'] );
	}

	return $form;
} );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.