diff --git a/gp-copy-cat/gpcc-field-indicators.php b/gp-copy-cat/gpcc-field-indicators.php new file mode 100644 index 000000000..91a33d6a6 --- /dev/null +++ b/gp-copy-cat/gpcc-field-indicators.php @@ -0,0 +1,77 @@ +formId ) { + return $content; + } + + $gpcc = new GP_Copy_Cat( 'fake.php' ); + $gpcc_fields = $gpcc->get_copy_cat_fields( GFAPI::get_form( $field->formId ) ); + if ( empty( $gpcc_fields ) ) { + return $content; + } + + if ( ! has_action( 'admin_footer', 'gpcc_field_indicator_styles' ) ) { + add_filter( 'admin_footer', 'gpcc_field_indicator_styles' ); + } + + $mappings = array(); + foreach ( $gpcc_fields as $_mappings ) { + $mappings = array_merge( $mappings, $_mappings ); + } + + $spans = array(); + + foreach ( $mappings as $mapping ) { + if ( $field->id == $mapping['source'] ) { + $spans['source'] = 'GPCC: Source'; + } + if ( $field->id == $mapping['target'] ) { + $spans['target'] = 'GPCC: Target'; + } + if ( $field->id == $mapping['trigger'] ) { + $spans['trigger'] = 'GPCC: Trigger'; + } + } + + $search = '<\/label>|<\/legend>'; + $replace = sprintf( '%s\0', implode( '', $spans ) ); + $content = preg_replace( "/$search/", $replace, $content, 1 ); + + return $content; +}, 11, 2 ); + +function gpcc_field_indicator_styles() { + ?> + +