Last active
          December 21, 2023 21:13 
        
      - 
      
- 
        Save rafaehlers/a4cfe84d0f527e603b3d749d642b1421 to your computer and use it in GitHub Desktop. 
    Filter for GravityMath to pull records from a secondary form
  
        
  
    
      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 // DO NOT COPY THIS LINE | |
| add_filter( 'gravityview/math/shortcode/before', function ( $formula ) { | |
| preg_match_all( '/~[^~]*?:(\d+(\.\d+)?|[a-z_]+)(:(.*?))?~/mi', $formula, $merge_tags, PREG_SET_ORDER ); | |
| foreach ( $merge_tags as $merge_tag ) { | |
| $updated_merge_tag = str_replace( '~', '', $merge_tag[0] ); | |
| $updated_merge_tag = sprintf( '{%s}', $updated_merge_tag ); | |
| $formula = str_replace( $merge_tag[0], $updated_merge_tag, $formula ); | |
| } | |
| return $formula; | |
| }, 9 ); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment